OSDN Git Service

Adding old unit tests to test suite.
authorjeffhao <jeffhao@google.com>
Fri, 30 Sep 2011 00:41:15 +0000 (17:41 -0700)
committerjeffhao <jeffhao@google.com>
Fri, 30 Sep 2011 00:41:15 +0000 (17:41 -0700)
These tests are copied straight over. They'll still run, but they're
using the old system.

Change-Id: If494519e52ddf858a9febfc55bdae830468cb3c8

456 files changed:
test/001-nop/build [new file with mode: 0644]
test/001-nop/expected.txt [new file with mode: 0644]
test/001-nop/info.txt [new file with mode: 0644]
test/001-nop/run [new file with mode: 0644]
test/002-sleep/expected.txt [new file with mode: 0644]
test/002-sleep/info.txt [new file with mode: 0644]
test/002-sleep/src/Main.java [new file with mode: 0644]
test/003-omnibus-opcodes/build [new file with mode: 0644]
test/003-omnibus-opcodes/expected.txt [new file with mode: 0644]
test/003-omnibus-opcodes/info.txt [new file with mode: 0644]
test/003-omnibus-opcodes/src/Array.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/Classes.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/Compare.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/FloatMath.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/Goto.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/InstField.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/IntMath.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/InternedString.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/Main.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/MethodCall.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/Monitor.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/StaticField.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/Switch.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/Throw.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/UnresClass.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/UnresStuff.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/UnresTest1.java [new file with mode: 0644]
test/003-omnibus-opcodes/src/UnresTest2.java [new file with mode: 0644]
test/003-omnibus-opcodes/src2/UnresStuff.java [new file with mode: 0644]
test/004-annotations/expected.txt [new file with mode: 0644]
test/004-annotations/info.txt [new file with mode: 0644]
test/004-annotations/src/Main.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoArrayField.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoFancyConstructor.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoFancyField.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoFancyMethod.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoFancyParameter.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoFancyType.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoSimpleConstructor.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoSimpleField.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoSimpleLocalVariable.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoSimpleMethod.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoSimplePackage.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoSimpleParameter.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoSimpleType.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoSimpleType2.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/AnnoSimpleTypeInvis.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/ExportedProperty.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/FullyNoted.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/INoted.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/IntToString.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/SimplyNoted.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/SomeClass.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/SubNoted.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/TestAnnotations.java [new file with mode: 0644]
test/004-annotations/src/android/test/anno/package-info.java [new file with mode: 0644]
test/005-args/expected.txt [new file with mode: 0644]
test/005-args/info.txt [new file with mode: 0644]
test/005-args/src/ArgsTest.java [new file with mode: 0644]
test/005-args/src/Main.java [new file with mode: 0644]
test/006-count10/expected.txt [new file with mode: 0644]
test/006-count10/info.txt [new file with mode: 0644]
test/006-count10/src/Main.java [new file with mode: 0644]
test/007-exceptions/expected.txt [new file with mode: 0644]
test/007-exceptions/info.txt [new file with mode: 0644]
test/007-exceptions/src/Main.java [new file with mode: 0644]
test/008-instanceof/expected.txt [new file with mode: 0644]
test/008-instanceof/info.txt [new file with mode: 0644]
test/008-instanceof/src/Iface1.java [new file with mode: 0644]
test/008-instanceof/src/Iface2.java [new file with mode: 0644]
test/008-instanceof/src/Iface2Sub1.java [new file with mode: 0644]
test/008-instanceof/src/ImplA.java [new file with mode: 0644]
test/008-instanceof/src/ImplB.java [new file with mode: 0644]
test/008-instanceof/src/ImplBSub.java [new file with mode: 0644]
test/008-instanceof/src/Main.java [new file with mode: 0644]
test/009-instanceof2/expected.txt [new file with mode: 0644]
test/009-instanceof2/info.txt [new file with mode: 0644]
test/009-instanceof2/src/Iface1.java [new file with mode: 0644]
test/009-instanceof2/src/Iface2.java [new file with mode: 0644]
test/009-instanceof2/src/Iface2Sub1.java [new file with mode: 0644]
test/009-instanceof2/src/ImplA.java [new file with mode: 0644]
test/009-instanceof2/src/ImplB.java [new file with mode: 0644]
test/009-instanceof2/src/ImplBSub.java [new file with mode: 0644]
test/009-instanceof2/src/Main.java [new file with mode: 0644]
test/010-instance/expected.txt [new file with mode: 0644]
test/010-instance/info.txt [new file with mode: 0644]
test/010-instance/src/InstanceTest.java [new file with mode: 0644]
test/010-instance/src/Main.java [new file with mode: 0644]
test/010-instance/src/X.java [new file with mode: 0644]
test/010-instance/src/Y.java [new file with mode: 0644]
test/011-array-copy/expected.txt [new file with mode: 0644]
test/011-array-copy/info.txt [new file with mode: 0644]
test/011-array-copy/src/Iface1.java [new file with mode: 0644]
test/011-array-copy/src/Iface2.java [new file with mode: 0644]
test/011-array-copy/src/ImplA.java [new file with mode: 0644]
test/011-array-copy/src/Main.java [new file with mode: 0644]
test/012-math/expected.txt [new file with mode: 0644]
test/012-math/info.txt [new file with mode: 0644]
test/012-math/src/Main.java [new file with mode: 0644]
test/013-math2/expected.txt [new file with mode: 0644]
test/013-math2/info.txt [new file with mode: 0644]
test/013-math2/src/Main.java [new file with mode: 0644]
test/014-math3/expected.txt [new file with mode: 0644]
test/014-math3/info.txt [new file with mode: 0644]
test/014-math3/src/Main.java [new file with mode: 0644]
test/015-switch/expected.txt [new file with mode: 0644]
test/015-switch/info.txt [new file with mode: 0644]
test/015-switch/src/Main.java [new file with mode: 0644]
test/016-intern/expected.txt [new file with mode: 0644]
test/016-intern/info.txt [new file with mode: 0644]
test/016-intern/src/Main.java [new file with mode: 0644]
test/017-float/expected.txt [new file with mode: 0644]
test/017-float/info.txt [new file with mode: 0644]
test/017-float/src/Main.java [new file with mode: 0644]
test/018-stack-overflow/expected.txt [new file with mode: 0644]
test/018-stack-overflow/info.txt [new file with mode: 0644]
test/018-stack-overflow/src/Main.java [new file with mode: 0644]
test/019-wrong-array-type/expected.txt [new file with mode: 0644]
test/019-wrong-array-type/info.txt [new file with mode: 0644]
test/019-wrong-array-type/src/Main.java [new file with mode: 0644]
test/020-string/expected.txt [new file with mode: 0644]
test/020-string/info.txt [new file with mode: 0644]
test/020-string/src/Main.java [new file with mode: 0644]
test/021-string2/expected.txt [new file with mode: 0644]
test/021-string2/info.txt [new file with mode: 0644]
test/021-string2/src/Main.java [new file with mode: 0644]
test/021-string2/src/junit/framework/Assert.java [new file with mode: 0644]
test/021-string2/src/junit/framework/AssertionFailedError.java [new file with mode: 0644]
test/021-string2/src/junit/framework/ComparisonFailure.java [new file with mode: 0644]
test/022-interface/expected.txt [new file with mode: 0644]
test/022-interface/info.txt [new file with mode: 0644]
test/022-interface/src/Iface1.java [new file with mode: 0644]
test/022-interface/src/Iface2.java [new file with mode: 0644]
test/022-interface/src/Iface2Sub1.java [new file with mode: 0644]
test/022-interface/src/ImplA.java [new file with mode: 0644]
test/022-interface/src/ImplB.java [new file with mode: 0644]
test/022-interface/src/ImplBSub.java [new file with mode: 0644]
test/022-interface/src/Main.java [new file with mode: 0644]
test/023-many-interfaces/build [new file with mode: 0644]
test/023-many-interfaces/expected.txt [new file with mode: 0644]
test/023-many-interfaces/iface-gen.c [new file with mode: 0644]
test/023-many-interfaces/info.txt [new file with mode: 0644]
test/023-many-interfaces/src/Main.java [new file with mode: 0644]
test/023-many-interfaces/src/ManyInterfaces.java [new file with mode: 0644]
test/024-illegal-access/expected.txt [new file with mode: 0644]
test/024-illegal-access/info.txt [new file with mode: 0644]
test/024-illegal-access/src/CheckInstanceof.java [new file with mode: 0644]
test/024-illegal-access/src/Main.java [new file with mode: 0644]
test/024-illegal-access/src/PublicAccess.java [new file with mode: 0644]
test/024-illegal-access/src/SemiPrivate.java [new file with mode: 0644]
test/024-illegal-access/src/otherpkg/Package.java [new file with mode: 0644]
test/024-illegal-access/src2/SemiPrivate.java [new file with mode: 0644]
test/024-illegal-access/src2/otherpkg/Package.java [new file with mode: 0644]
test/025-access-controller/expected.txt [new file with mode: 0644]
test/025-access-controller/info.txt [new file with mode: 0644]
test/025-access-controller/src/Main.java [new file with mode: 0644]
test/025-access-controller/src/Privvy.java [new file with mode: 0644]
test/026-access/expected.txt [new file with mode: 0644]
test/026-access/info.txt [new file with mode: 0644]
test/026-access/src/Main.java [new file with mode: 0644]
test/026-access/src/otherpackage/PublicAccess.java [new file with mode: 0644]
test/027-arithmetic/expected.txt [new file with mode: 0644]
test/027-arithmetic/info.txt [new file with mode: 0644]
test/027-arithmetic/src/Main.java [new file with mode: 0644]
test/028-array-write/expected.txt [new file with mode: 0644]
test/028-array-write/info.txt [new file with mode: 0644]
test/028-array-write/src/Main.java [new file with mode: 0644]
test/029-assert/expected.txt [new file with mode: 0644]
test/029-assert/info.txt [new file with mode: 0644]
test/029-assert/src/Main.java [new file with mode: 0644]
test/030-bad-finalizer/expected.txt [new file with mode: 0644]
test/030-bad-finalizer/info.txt [new file with mode: 0644]
test/030-bad-finalizer/src/BadFinalizer.java [new file with mode: 0644]
test/030-bad-finalizer/src/Main.java [new file with mode: 0644]
test/031-class-attributes/expected.txt [new file with mode: 0644]
test/031-class-attributes/info.txt [new file with mode: 0644]
test/031-class-attributes/src/ClassAttrs.java [new file with mode: 0644]
test/031-class-attributes/src/Main.java [new file with mode: 0644]
test/031-class-attributes/src/OtherClass.java [new file with mode: 0644]
test/031-class-attributes/src/otherpackage/OtherPackageClass.java [new file with mode: 0644]
test/032-concrete-sub/expected.txt [new file with mode: 0644]
test/032-concrete-sub/info.txt [new file with mode: 0644]
test/032-concrete-sub/src/AbstractBase.java [new file with mode: 0644]
test/032-concrete-sub/src/ConcreteSub.java [new file with mode: 0644]
test/032-concrete-sub/src/ConcreteSub2.java [new file with mode: 0644]
test/032-concrete-sub/src/Main.java [new file with mode: 0644]
test/032-concrete-sub/src2/AbstractBase.java [new file with mode: 0644]
test/033-class-init-deadlock/expected.txt [new file with mode: 0644]
test/033-class-init-deadlock/info.txt [new file with mode: 0644]
test/033-class-init-deadlock/src/Main.java [new file with mode: 0644]
test/034-call-null/expected.txt [new file with mode: 0644]
test/034-call-null/info.txt [new file with mode: 0644]
test/034-call-null/src/Main.java [new file with mode: 0644]
test/035-enum/expected.txt [new file with mode: 0644]
test/035-enum/info.txt [new file with mode: 0644]
test/035-enum/src/Main.java [new file with mode: 0644]
test/036-finalizer/expected.txt [new file with mode: 0644]
test/036-finalizer/info.txt [new file with mode: 0644]
test/036-finalizer/src/FinalizerTest.java [new file with mode: 0644]
test/036-finalizer/src/Main.java [new file with mode: 0644]
test/037-inherit/expected.txt [new file with mode: 0644]
test/037-inherit/info.txt [new file with mode: 0644]
test/037-inherit/src/Main.java [new file with mode: 0644]
test/038-inner-null/expected.txt [new file with mode: 0644]
test/038-inner-null/info.txt [new file with mode: 0644]
test/038-inner-null/src/Main.java [new file with mode: 0644]
test/039-join-main/expected.txt [new file with mode: 0644]
test/039-join-main/info.txt [new file with mode: 0644]
test/039-join-main/src/Main.java [new file with mode: 0644]
test/040-miranda/expected.txt [new file with mode: 0644]
test/040-miranda/info.txt [new file with mode: 0644]
test/040-miranda/src/Main.java [new file with mode: 0644]
test/040-miranda/src/MirandaAbstract.java [new file with mode: 0644]
test/040-miranda/src/MirandaClass.java [new file with mode: 0644]
test/040-miranda/src/MirandaClass2.java [new file with mode: 0644]
test/040-miranda/src/MirandaInterface.java [new file with mode: 0644]
test/040-miranda/src/MirandaInterface2.java [new file with mode: 0644]
test/041-narrowing/expected.txt [new file with mode: 0644]
test/041-narrowing/info.txt [new file with mode: 0644]
test/041-narrowing/src/Main.java [new file with mode: 0644]
test/042-new-instance/expected.txt [new file with mode: 0644]
test/042-new-instance/info.txt [new file with mode: 0644]
test/042-new-instance/src/Main.java [new file with mode: 0644]
test/042-new-instance/src/MaybeAbstract.java [new file with mode: 0644]
test/042-new-instance/src/otherpackage/PackageAccess.java [new file with mode: 0644]
test/042-new-instance/src2/MaybeAbstract.java [new file with mode: 0644]
test/043-privates/expected.txt [new file with mode: 0644]
test/043-privates/info.txt [new file with mode: 0644]
test/043-privates/src/Main.java [new file with mode: 0644]
test/044-proxy/expected.txt [new file with mode: 0644]
test/044-proxy/info.txt [new file with mode: 0644]
test/044-proxy/src/BasicTest.java [new file with mode: 0644]
test/044-proxy/src/Clash.java [new file with mode: 0644]
test/044-proxy/src/Clash2.java [new file with mode: 0644]
test/044-proxy/src/Clash3.java [new file with mode: 0644]
test/044-proxy/src/Clash4.java [new file with mode: 0644]
test/044-proxy/src/Main.java [new file with mode: 0644]
test/044-proxy/src/WrappedThrow.java [new file with mode: 0644]
test/045-reflect-array/expected.txt [new file with mode: 0644]
test/045-reflect-array/info.txt [new file with mode: 0644]
test/045-reflect-array/src/Main.java [new file with mode: 0644]
test/046-reflect/expected.txt [new file with mode: 0644]
test/046-reflect/info.txt [new file with mode: 0644]
test/046-reflect/src/Main.java [new file with mode: 0644]
test/047-returns/expected.txt [new file with mode: 0644]
test/047-returns/info.txt [new file with mode: 0644]
test/047-returns/src/Main.java [new file with mode: 0644]
test/048-server-socket/expected.txt [new file with mode: 0644]
test/048-server-socket/info.txt [new file with mode: 0644]
test/048-server-socket/src/Main.java [new file with mode: 0644]
test/049-show-object/expected.txt [new file with mode: 0644]
test/049-show-object/info.txt [new file with mode: 0644]
test/049-show-object/src/Main.java [new file with mode: 0644]
test/050-sync-test/expected.txt [new file with mode: 0644]
test/050-sync-test/info.txt [new file with mode: 0644]
test/050-sync-test/src/Main.java [new file with mode: 0644]
test/050-sync-test/src/ThreadDeathHandler.java [new file with mode: 0644]
test/051-thread/expected.txt [new file with mode: 0644]
test/051-thread/info.txt [new file with mode: 0644]
test/051-thread/src/Main.java [new file with mode: 0644]
test/052-verifier-fun/expected.txt [new file with mode: 0644]
test/052-verifier-fun/info.txt [new file with mode: 0644]
test/052-verifier-fun/src/Blah.java [new file with mode: 0644]
test/052-verifier-fun/src/BlahFeature.java [new file with mode: 0644]
test/052-verifier-fun/src/BlahOne.java [new file with mode: 0644]
test/052-verifier-fun/src/BlahTwo.java [new file with mode: 0644]
test/052-verifier-fun/src/Main.java [new file with mode: 0644]
test/053-wait-some/expected.txt [new file with mode: 0644]
test/053-wait-some/info.txt [new file with mode: 0644]
test/053-wait-some/src/Main.java [new file with mode: 0644]
test/054-uncaught/expected.txt [new file with mode: 0644]
test/054-uncaught/info.txt [new file with mode: 0644]
test/054-uncaught/src/Main.java [new file with mode: 0644]
test/054-uncaught/src/ThreadDeathHandler.java [new file with mode: 0644]
test/055-enum-performance/expected.txt [new file with mode: 0644]
test/055-enum-performance/info.txt [new file with mode: 0644]
test/055-enum-performance/src/Main.java [new file with mode: 0644]
test/055-enum-performance/src/SamePackagePrivateEnum.java [new file with mode: 0644]
test/055-enum-performance/src/SamePackagePublicEnum.java [new file with mode: 0644]
test/055-enum-performance/src/otherpackage/OtherPackagePublicEnum.java [new file with mode: 0644]
test/056-const-string-jumbo/build [new file with mode: 0644]
test/056-const-string-jumbo/expected.txt [new file with mode: 0644]
test/056-const-string-jumbo/info.txt [new file with mode: 0644]
test/056-const-string-jumbo/src/Main.java [new file with mode: 0644]
test/058-enum-order/expected.txt [new file with mode: 0644]
test/058-enum-order/info.txt [new file with mode: 0644]
test/058-enum-order/src/Main.java [new file with mode: 0644]
test/059-finalizer-throw/expected.txt [new file with mode: 0644]
test/059-finalizer-throw/info.txt [new file with mode: 0644]
test/059-finalizer-throw/src/Main.java [new file with mode: 0644]
test/061-out-of-memory/expected.txt [new file with mode: 0644]
test/061-out-of-memory/info.txt [new file with mode: 0644]
test/061-out-of-memory/src/Main.java [new file with mode: 0644]
test/062-character-encodings/expected.txt [new file with mode: 0644]
test/062-character-encodings/info.txt [new file with mode: 0644]
test/062-character-encodings/src/Main.java [new file with mode: 0644]
test/063-process-manager/expected.txt [new file with mode: 0644]
test/063-process-manager/info.txt [new file with mode: 0644]
test/063-process-manager/src/Main.java [new file with mode: 0644]
test/064-field-access/expected.txt [new file with mode: 0644]
test/064-field-access/info.txt [new file with mode: 0644]
test/064-field-access/src/GetNonexistent.java [new file with mode: 0644]
test/064-field-access/src/Holder.java [new file with mode: 0644]
test/064-field-access/src/Main.java [new file with mode: 0644]
test/064-field-access/src/other/OtherPackage.java [new file with mode: 0644]
test/064-field-access/src2/Holder.java [new file with mode: 0644]
test/065-mismatched-implements/expected.txt [new file with mode: 0644]
test/065-mismatched-implements/info.txt [new file with mode: 0644]
test/065-mismatched-implements/src/Base.java [new file with mode: 0644]
test/065-mismatched-implements/src/Defs.java [new file with mode: 0644]
test/065-mismatched-implements/src/Indirect.java [new file with mode: 0644]
test/065-mismatched-implements/src/Main.java [new file with mode: 0644]
test/065-mismatched-implements/src2/Defs.java [new file with mode: 0644]
test/066-mismatched-super/expected.txt [new file with mode: 0644]
test/066-mismatched-super/info.txt [new file with mode: 0644]
test/066-mismatched-super/src/Base.java [new file with mode: 0644]
test/066-mismatched-super/src/Defs.java [new file with mode: 0644]
test/066-mismatched-super/src/Indirect.java [new file with mode: 0644]
test/066-mismatched-super/src/Main.java [new file with mode: 0644]
test/066-mismatched-super/src2/Defs.java [new file with mode: 0644]
test/067-preemptive-unpark/expected.txt [new file with mode: 0644]
test/067-preemptive-unpark/info.txt [new file with mode: 0644]
test/067-preemptive-unpark/src/Main.java [new file with mode: 0644]
test/068-classloader/expected.txt [new file with mode: 0644]
test/068-classloader/info.txt [new file with mode: 0644]
test/068-classloader/src-ex/AbstractGet.java [new file with mode: 0644]
test/068-classloader/src-ex/DoubledExtend.java [new file with mode: 0644]
test/068-classloader/src-ex/DoubledExtendOkay.java [new file with mode: 0644]
test/068-classloader/src-ex/DoubledImplement.java [new file with mode: 0644]
test/068-classloader/src-ex/DoubledImplement2.java [new file with mode: 0644]
test/068-classloader/src-ex/GetDoubled.java [new file with mode: 0644]
test/068-classloader/src-ex/IfaceImpl.java [new file with mode: 0644]
test/068-classloader/src-ex/IfaceSub.java [new file with mode: 0644]
test/068-classloader/src-ex/Inaccessible1.java [new file with mode: 0644]
test/068-classloader/src-ex/Inaccessible2.java [new file with mode: 0644]
test/068-classloader/src-ex/Inaccessible3.java [new file with mode: 0644]
test/068-classloader/src/Base.java [new file with mode: 0644]
test/068-classloader/src/BaseOkay.java [new file with mode: 0644]
test/068-classloader/src/DoubledExtend.java [new file with mode: 0644]
test/068-classloader/src/DoubledExtendOkay.java [new file with mode: 0644]
test/068-classloader/src/DoubledImplement.java [new file with mode: 0644]
test/068-classloader/src/DoubledImplement2.java [new file with mode: 0644]
test/068-classloader/src/FancyLoader.java [new file with mode: 0644]
test/068-classloader/src/ICommon.java [new file with mode: 0644]
test/068-classloader/src/ICommon2.java [new file with mode: 0644]
test/068-classloader/src/IGetDoubled.java [new file with mode: 0644]
test/068-classloader/src/IfaceSuper.java [new file with mode: 0644]
test/068-classloader/src/InaccessibleBase.java [new file with mode: 0644]
test/068-classloader/src/InaccessibleInterface.java [new file with mode: 0644]
test/068-classloader/src/Main.java [new file with mode: 0644]
test/068-classloader/src/SimpleBase.java [new file with mode: 0644]
test/068-classloader/src/Useless.java [new file with mode: 0644]
test/069-field-type/expected.txt [new file with mode: 0644]
test/069-field-type/info.txt [new file with mode: 0644]
test/069-field-type/src/Blah.java [new file with mode: 0644]
test/069-field-type/src/Holder.java [new file with mode: 0644]
test/069-field-type/src/Main.java [new file with mode: 0644]
test/069-field-type/src2/Blah.java [new file with mode: 0644]
test/070-nio-buffer/expected.txt [new file with mode: 0644]
test/070-nio-buffer/info.txt [new file with mode: 0644]
test/070-nio-buffer/src/Main.java [new file with mode: 0644]
test/071-dexfile/expected.txt [new file with mode: 0644]
test/071-dexfile/info.txt [new file with mode: 0644]
test/071-dexfile/src-ex/Another.java [new file with mode: 0644]
test/071-dexfile/src/Main.java [new file with mode: 0644]
test/072-precise-gc/expected.txt [new file with mode: 0644]
test/072-precise-gc/info.txt [new file with mode: 0644]
test/072-precise-gc/src/Main.java [new file with mode: 0644]
test/073-mismatched-field/expected.txt [new file with mode: 0644]
test/073-mismatched-field/info.txt [new file with mode: 0644]
test/073-mismatched-field/src/IMain.java [new file with mode: 0644]
test/073-mismatched-field/src/Main.java [new file with mode: 0644]
test/073-mismatched-field/src/SuperMain.java [new file with mode: 0644]
test/073-mismatched-field/src2/IMain.java [new file with mode: 0644]
test/074-gc-thrash/expected.txt [new file with mode: 0644]
test/074-gc-thrash/info.txt [new file with mode: 0644]
test/074-gc-thrash/src/Main.java [new file with mode: 0644]
test/075-verification-error/expected.txt [new file with mode: 0644]
test/075-verification-error/info.txt [new file with mode: 0644]
test/075-verification-error/src/Main.java [new file with mode: 0644]
test/075-verification-error/src/MaybeAbstract.java [new file with mode: 0644]
test/075-verification-error/src/other/InaccessibleClass.java [new file with mode: 0644]
test/075-verification-error/src/other/InaccessibleMethod.java [new file with mode: 0644]
test/075-verification-error/src/other/Mutant.java [new file with mode: 0644]
test/075-verification-error/src2/MaybeAbstract.java [new file with mode: 0644]
test/075-verification-error/src2/other/InaccessibleClass.java [new file with mode: 0644]
test/075-verification-error/src2/other/InaccessibleMethod.java [new file with mode: 0644]
test/075-verification-error/src2/other/Mutant.java [new file with mode: 0644]
test/076-boolean-put/expected.txt [new file with mode: 0644]
test/076-boolean-put/info.txt [new file with mode: 0644]
test/076-boolean-put/src/Main.java [new file with mode: 0644]
test/077-method-override/expected.txt [new file with mode: 0644]
test/077-method-override/info.txt [new file with mode: 0644]
test/077-method-override/src/Base.java [new file with mode: 0644]
test/077-method-override/src/Derived.java [new file with mode: 0644]
test/077-method-override/src/Main.java [new file with mode: 0644]
test/077-method-override/src2/Base.java [new file with mode: 0644]
test/078-polymorphic-virtual/expected.txt [new file with mode: 0644]
test/078-polymorphic-virtual/info.txt [new file with mode: 0644]
test/078-polymorphic-virtual/src/Base.java [new file with mode: 0644]
test/078-polymorphic-virtual/src/Derived1.java [new file with mode: 0644]
test/078-polymorphic-virtual/src/Derived2.java [new file with mode: 0644]
test/078-polymorphic-virtual/src/Derived3.java [new file with mode: 0644]
test/078-polymorphic-virtual/src/Main.java [new file with mode: 0644]
test/079-phantom/expected.txt [new file with mode: 0644]
test/079-phantom/info.txt [new file with mode: 0644]
test/079-phantom/src/Bitmap.java [new file with mode: 0644]
test/079-phantom/src/Main.java [new file with mode: 0644]
test/080-oom-throw/expected.txt [new file with mode: 0644]
test/080-oom-throw/info.txt [new file with mode: 0644]
test/080-oom-throw/src/Main.java [new file with mode: 0644]
test/081-hot-exceptions/expected.txt [new file with mode: 0644]
test/081-hot-exceptions/info.txt [new file with mode: 0644]
test/081-hot-exceptions/src/Main.java [new file with mode: 0644]
test/082-inline-execute/expected.txt [new file with mode: 0644]
test/082-inline-execute/info.txt [new file with mode: 0644]
test/082-inline-execute/src/Main.java [new file with mode: 0644]
test/082-inline-execute/src/junit/framework/Assert.java [new file with mode: 0644]
test/082-inline-execute/src/junit/framework/AssertionFailedError.java [new file with mode: 0644]
test/082-inline-execute/src/junit/framework/ComparisonFailure.java [new file with mode: 0644]
test/083-jit-regressions/expected.txt [new file with mode: 0644]
test/083-jit-regressions/info.txt [new file with mode: 0644]
test/083-jit-regressions/src/Main.java [new file with mode: 0644]
test/084-class-init/expected.txt [new file with mode: 0644]
test/084-class-init/info.txt [new file with mode: 0644]
test/084-class-init/src/IntHolder.java [new file with mode: 0644]
test/084-class-init/src/Main.java [new file with mode: 0644]
test/084-class-init/src/PartialInit.java [new file with mode: 0644]
test/084-class-init/src/SlowInit.java [new file with mode: 0644]
test/085-old-style-inner-class/build [new file with mode: 0644]
test/085-old-style-inner-class/expected.txt [new file with mode: 0644]
test/085-old-style-inner-class/info.txt [new file with mode: 0644]
test/085-old-style-inner-class/src/Main.java [new file with mode: 0644]
test/086-null-super/expected.txt [new file with mode: 0644]
test/086-null-super/info.txt [new file with mode: 0644]
test/086-null-super/src/Main.java [new file with mode: 0644]
test/087-gc-after-link/expected.txt [new file with mode: 0644]
test/087-gc-after-link/info.txt [new file with mode: 0644]
test/087-gc-after-link/src/Main.java [new file with mode: 0644]
test/088-monitor-verification/expected.txt [new file with mode: 0644]
test/088-monitor-verification/info.txt [new file with mode: 0644]
test/088-monitor-verification/src/Main.java [new file with mode: 0644]
test/088-monitor-verification/src/MyException.java [new file with mode: 0644]
test/088-monitor-verification/src/TooDeep.java [new file with mode: 0644]
test/090-loop-formation/expected.txt [new file with mode: 0644]
test/090-loop-formation/info.txt [new file with mode: 0644]
test/090-loop-formation/src/Main.java [new file with mode: 0644]
test/MemUsage/MemUsage.java.orig [new file with mode: 0644]
test/README.txt [new file with mode: 0644]
test/etc/default-build [new file with mode: 0755]
test/etc/default-run [new file with mode: 0755]
test/etc/host-run-test-jar [new file with mode: 0755]
test/etc/push-and-run-test-jar [new file with mode: 0755]
test/etc/reference-run-test-classes [new file with mode: 0755]
test/run-all-tests [new file with mode: 0755]
test/run-test [new file with mode: 0755]

diff --git a/test/001-nop/build b/test/001-nop/build
new file mode 100644 (file)
index 0000000..5233a2d
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+# Nothing to do here.
diff --git a/test/001-nop/expected.txt b/test/001-nop/expected.txt
new file mode 100644 (file)
index 0000000..80a233e
--- /dev/null
@@ -0,0 +1 @@
+Blort.
diff --git a/test/001-nop/info.txt b/test/001-nop/info.txt
new file mode 100644 (file)
index 0000000..9942f10
--- /dev/null
@@ -0,0 +1,2 @@
+This is a sample no-op test, which does at least serve to verify that the
+test harness is working.
diff --git a/test/001-nop/run b/test/001-nop/run
new file mode 100644 (file)
index 0000000..210296b
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo "Blort."
diff --git a/test/002-sleep/expected.txt b/test/002-sleep/expected.txt
new file mode 100644 (file)
index 0000000..f994ce5
--- /dev/null
@@ -0,0 +1,2 @@
+Sleeping 1000 msec...
+Done sleeping
diff --git a/test/002-sleep/info.txt b/test/002-sleep/info.txt
new file mode 100644 (file)
index 0000000..9a0afe9
--- /dev/null
@@ -0,0 +1,3 @@
+Test that Thread.sleep() operates reasonably. This test is actually
+mostly meant as an easy thing to modify in order to test other things
+in an ad-hoc way.
diff --git a/test/002-sleep/src/Main.java b/test/002-sleep/src/Main.java
new file mode 100644 (file)
index 0000000..c1a2d83
--- /dev/null
@@ -0,0 +1,22 @@
+public class Main {
+    static public void main(String[] args) throws Exception {
+        int millis = 1000;
+
+        if (args.length != 0) {
+            millis = Integer.parseInt(args[0]);
+        }
+
+        System.out.println("Sleeping " + millis + " msec...");
+
+        long start = System.currentTimeMillis();
+        Thread.sleep(millis);
+        long elapsed = System.currentTimeMillis() - start;
+        long offBy = Math.abs(elapsed - millis);
+
+        System.out.println("Done sleeping");
+
+        if (offBy > 250) {
+            System.out.println("Actually slept about " + elapsed + " msec...");
+        }
+    }
+}
diff --git a/test/003-omnibus-opcodes/build b/test/003-omnibus-opcodes/build
new file mode 100644 (file)
index 0000000..9eb5ed3
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+#
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# 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.
+
+# Stop if something fails.
+set -e
+
+mkdir classes
+${JAVAC} -d classes `find src -name '*.java'`
+rm classes/UnresClass.class
+${JAVAC} -d classes `find src2 -name '*.java'`
+
+dx -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex classes
+zip test.jar classes.dex
diff --git a/test/003-omnibus-opcodes/expected.txt b/test/003-omnibus-opcodes/expected.txt
new file mode 100644 (file)
index 0000000..4895dc3
--- /dev/null
@@ -0,0 +1,74 @@
+(assertions are enabled)
+InstField assign...
+InstField check...
+InstField.nullCheck
+StaticField assign...
+StaticField check...
+IntMath.shiftTest1
+IntMath.shiftTest2
+IntMath.unsignedShiftTest
+IntMath.convTest
+IntMath.charSubTest
+IntMath.intOperTest
+IntMath.intOperCheck
+IntMath.longOperTest
+IntMath.longOperCheck
+IntMath.lit16Test
+IntMath.lit8Test
+IntMath.intShiftTest
+IntMath.intShiftCheck
+IntMath.longShiftTest
+IntMath.longShiftCheck
+IntMath.truncateTest
+IntMath.divideByZero
+IntMath.bigDivideOverflow
+IntMath.checkConsts
+IntMath.jlmTests
+FloatMath.convTest
+FloatMath.floatOperTest
+FloatMath.doubleOperTest
+FloatMath.checkConvI
+FloatMath.checkConvL
+FloatMath.checkConvF
+ 0: -2.0054409E9
+ 1: -8.613303E18
+ 2: -3.1415927
+-2.0054409E9, -8.6133031E18, -3.1415927
+FloatMath.checkConvD
+ 0: -2.005440939E9
+ 1: -8.613303245920329E18
+ 2: 123.45600128173828
+-2.005440939E9, -8.6133032459203287E18, 123.4560012817382
+FloatMath.checkConsts
+FloatMath.jlmTests
+IntMath.testIntCompare
+IntMath.testLongCompare
+IntMath.testFloatCompare
+IntMath.testDoubleCompare
+Monitor.run
+Switch.testSwitch
+Array check...
+Array.checkRange32
+Array.checkRange64
+Array.checkNegAlloc
+Classes.checkCast
+Classes.arrayInstance
+Goto.smallGoto
+Goto.smallGoto
+Goto.mediumGoto
+Goto.mediumGoto
+Goto.bigGoto
+Goto.bigGoto
+  MethodCallBase ctor
+  MethodCall ctor
+MethodCalls.manyArgs
+Throw.one
+Throw.twoA
+Throw.twoN
+Throw.rethrow
+UnresTest1...
+UnresTest1...
+UnresTest2...
+UnresTest2 done
+InternedString.run
+Done!
diff --git a/test/003-omnibus-opcodes/info.txt b/test/003-omnibus-opcodes/info.txt
new file mode 100644 (file)
index 0000000..6c0fbda
--- /dev/null
@@ -0,0 +1 @@
+This is a smoke test of many Dalvik opcodes.
diff --git a/test/003-omnibus-opcodes/src/Array.java b/test/003-omnibus-opcodes/src/Array.java
new file mode 100644 (file)
index 0000000..f385dd8
--- /dev/null
@@ -0,0 +1,224 @@
+// Copyright 2008 The Android Open Source Project
+
+
+/**
+ * Exercise arrays.
+ */
+public class Array {
+
+    /*
+     * Verify array contents.
+     */
+    static void checkBytes(byte[] bytes) {
+        assert(bytes[0] == 0);
+        assert(bytes[1] == -1);
+        assert(bytes[2] == -2);
+        assert(bytes[3] == -3);
+        assert(bytes[4] == -4);
+    }
+    static void checkShorts(short[] shorts) {
+        assert(shorts[0] == 20);
+        assert(shorts[1] == 10);
+        assert(shorts[2] == 0);
+        assert(shorts[3] == -10);
+        assert(shorts[4] == -20);
+    }
+    static void checkChars(char[] chars) {
+        assert(chars[0] == 40000);
+        assert(chars[1] == 40001);
+        assert(chars[2] == 40002);
+        assert(chars[3] == 40003);
+        assert(chars[4] == 40004);
+    }
+    static void checkInts(int[] ints) {
+        assert(ints[0] == 70000);
+        assert(ints[1] == 70001);
+        assert(ints[2] == 70002);
+        assert(ints[3] == 70003);
+        assert(ints[4] == 70004);
+    }
+    static void checkBooleans(boolean[] booleans) {
+        assert(booleans[0]);
+        assert(booleans[1]);
+        assert(!booleans[2]);
+        assert(booleans[3]);
+        assert(!booleans[4]);
+    }
+    static void checkFloats(float[] floats) {
+        assert(floats[0] == -1.5);
+        assert(floats[1] == -0.5);
+        assert(floats[2] == 0.0);
+        assert(floats[3] == 0.5);
+        assert(floats[4] == 1.5);
+    }
+    static void checkLongs(long[] longs) {
+        assert(longs[0] == 0x1122334455667788L);
+        assert(longs[1] == 0x8877665544332211L);
+        assert(longs[2] == 0L);
+        assert(longs[3] == 1L);
+        assert(longs[4] == -1L);
+    }
+    static void checkStrings(String[] strings) {
+        assert(strings[0].equals("zero"));
+        assert(strings[1].equals("one"));
+        assert(strings[2].equals("two"));
+        assert(strings[3].equals("three"));
+        assert(strings[4].equals("four"));
+    }
+
+    /*
+     * Try bad range values, 32 bit get/put.
+     */
+    static void checkRange32(int[] ints, int[] empty, int negVal1, int negVal2){
+        System.out.println("Array.checkRange32");
+        int i = 0;
+
+        assert(ints.length == 5);
+
+        try {
+            i = ints[5];            // exact bound
+            assert(false);
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            // good
+        }
+        try {
+            ints[5] = i;            // exact bound
+            assert(false);
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            // good
+        }
+        try {
+            i = ints[6];            // one past
+            assert(false);
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            // good
+        }
+        try {
+            i = ints[negVal1];      // -1
+            assert(false);
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            // good
+        }
+        try {
+            ints[negVal1] = i;      // -1
+            assert(false);
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            // good
+        }
+        try {
+            i = ints[negVal2];      // min int
+            assert(false);
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            // good
+        }
+
+
+        try {
+            i = empty[1];
+            assert(false);
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            // good
+        }
+    }
+
+    /*
+     * Try bad range values, 64 bit get/put.
+     */
+    static void checkRange64(long[] longs, int negVal1, int negVal2) {
+        System.out.println("Array.checkRange64");
+        long l = 0L;
+
+        assert(longs.length == 5);
+
+        try {
+            l = longs[5];            // exact bound
+            assert(false);
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            // good
+        }
+        try {
+            longs[5] = l;            // exact bound
+            assert(false);
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            // good
+        }
+        try {
+            l = longs[6];            // one past
+            assert(false);
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            // good
+        }
+        try {
+            l = longs[negVal1];      // -1
+            assert(false);
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            // good
+        }
+        try {
+            longs[negVal1] = l;      // -1
+            assert(false);
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            // good
+        }
+        try {
+            l = longs[negVal2];      // min int
+            assert(false);
+        } catch (ArrayIndexOutOfBoundsException aioobe) {
+            // good
+        }
+    }
+
+    /*
+     * Test negative allocations of object and primitive arrays.
+     */
+    static void checkNegAlloc(int count) {
+        System.out.println("Array.checkNegAlloc");
+        String[] strings;
+        int[] ints;
+
+        try {
+            ints = new int[count];
+            assert(false);
+        } catch (NegativeArraySizeException nase) {
+            // good
+        }
+
+        try {
+            strings = new String[count];
+            assert(false);
+        } catch (NegativeArraySizeException nase) {
+            // good
+        }
+    }
+
+    public static void run() {
+        System.out.println("Array check...");
+
+        byte[] xBytes = new byte[] { 0, -1, -2, -3, -4 };
+        short[] xShorts = new short[] { 20, 10, 0, -10, -20 };
+        char[] xChars = new char[] { 40000, 40001, 40002, 40003, 40004 };
+        int[] xInts = new int[] { 70000, 70001, 70002, 70003, 70004 };
+        boolean[] xBooleans = new boolean[] { true, true, false, true, false };
+        float[] xFloats = new float[] { -1.5f, -0.5f, 0.0f, 0.5f, 1.5f };
+        long[] xLongs = new long[] {
+            0x1122334455667788L, 0x8877665544332211L, 0L, 1L, -1l };
+        String[] xStrings = new String[] {
+            "zero", "one", "two", "three", "four" };
+
+        int[] xEmpty = new int[0];
+
+        checkBytes(xBytes);
+        checkShorts(xShorts);
+        checkChars(xChars);
+        checkInts(xInts);
+        checkBooleans(xBooleans);
+        checkFloats(xFloats);
+        checkLongs(xLongs);
+        checkStrings(xStrings);
+
+        checkRange32(xInts, xEmpty, -1, (int) 0x80000000);
+        checkRange64(xLongs, -1, (int) 0x80000000);
+
+        checkNegAlloc(-1);
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/Classes.java b/test/003-omnibus-opcodes/src/Classes.java
new file mode 100644 (file)
index 0000000..c89ff3e
--- /dev/null
@@ -0,0 +1,219 @@
+// Copyright 2008 The Android Open Source Project
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+/**
+ * Exercise some class-related instructions.
+ */
+public class Classes {
+    int mSome;
+
+    public void subFunc(boolean wantSub) {
+        assert(!wantSub);
+    }
+
+    void checkCast(Object thisRef, Object moreRef, Object nullRef) {
+        System.out.println("Classes.checkCast");
+
+        Classes classes;
+        MoreClasses more;
+
+        classes = (Classes) thisRef;
+        assert(thisRef instanceof Classes);
+        classes = (Classes) moreRef;
+        assert(moreRef instanceof Classes);
+
+        more = (MoreClasses) moreRef;
+        assert(moreRef instanceof MoreClasses);
+        assert(!(thisRef instanceof MoreClasses));
+
+        try {
+            more = (MoreClasses) thisRef;
+            assert(false);
+        } catch (ClassCastException cce) {
+            //System.out.println("  class cast msg: " + cce.getMessage());
+            //Dalvik throws terser message than Hotspot VM
+            assert(cce.getMessage().regionMatches(false, 0, "Classes", 0, 7));
+        }
+        assert(!(thisRef instanceof MoreClasses));
+
+        /* hopefully these classes cause a resolve */
+        try {
+            java.math.RoundingMode mode = (java.math.RoundingMode) thisRef;
+            assert(false);
+        } catch (ClassCastException cce) {
+            //System.out.println("  class cast msg: " + cce.getMessage());
+            //Dalvik throws terser message than Hotspot VM
+            assert(cce.getMessage().regionMatches(false, 0, "Classes", 0, 7));
+        }
+        assert(!(thisRef instanceof java.math.BigDecimal));
+
+        /* try some stuff with a null reference */
+        classes = (Classes) nullRef;
+        classes = (MoreClasses) nullRef;
+        more = (MoreClasses) nullRef;
+        assert(!(nullRef instanceof Classes));
+
+    }
+
+
+    static void xTests(Object x) {
+        assert(  x instanceof Classes);
+        assert(!(x instanceof MoreClasses));
+    }
+    static void yTests(Object y) {
+        assert(  y instanceof Classes);
+        assert(  y instanceof MoreClasses);
+    }
+    static void xarTests(Object xar) {
+        assert(  xar instanceof Object);
+        assert(!(xar instanceof Classes));
+        assert(  xar instanceof Classes[]);
+        assert(!(xar instanceof MoreClasses[]));
+        assert(  xar instanceof Object[]);
+        assert(!(xar instanceof Object[][]));
+    }
+    static void yarTests(Object yar) {
+        assert(  yar instanceof Classes[]);
+        assert(  yar instanceof MoreClasses[]);
+    }
+    static void xarararTests(Object xararar) {
+        assert(  xararar instanceof Object);
+        assert(  xararar instanceof Object[]);
+        assert(!(xararar instanceof Classes));
+        assert(!(xararar instanceof Classes[]));
+        assert(!(xararar instanceof Classes[][]));
+        assert(  xararar instanceof Classes[][][]);
+        assert(!(xararar instanceof MoreClasses[][][]));
+        assert(  xararar instanceof Object[][][]);
+        assert(  xararar instanceof Serializable);
+        assert(  xararar instanceof Serializable[]);
+        assert(  xararar instanceof Serializable[][]);
+        assert(!(xararar instanceof Serializable[][][]));
+    }
+    static void yarararTests(Object yararar) {
+        assert(  yararar instanceof Classes[][][]);
+        assert(  yararar instanceof MoreClasses[][][]);
+    }
+    static void iarTests(Object iar) {
+        assert(  iar instanceof Object);
+        assert(!(iar instanceof Object[]));
+    }
+    static void iararTests(Object iarar) {
+        assert(  iarar instanceof Object);
+        assert(  iarar instanceof Object[]);
+        assert(!(iarar instanceof Object[][]));
+    }
+
+    /*
+     * Exercise filled-new-array and test instanceof on arrays.
+     *
+     * We call out instead of using "instanceof" directly to avoid
+     * compiler optimizations.
+     */
+    static void arrayInstance() {
+        System.out.println("Classes.arrayInstance");
+
+        Classes x = new Classes();
+        Classes[] xar = new Classes[1];
+        Classes[][] xarar = new Classes[1][1];
+        Classes[][][] xararar = new Classes[1][2][3];
+        MoreClasses y = new MoreClasses();
+        MoreClasses[] yar = new MoreClasses[3];
+        MoreClasses[][] yarar = new MoreClasses[2][3];
+        MoreClasses[][][] yararar = new MoreClasses[1][2][3];
+        int[] iar = new int[1];
+        int[][] iarar = new int[1][1];
+        Object test;
+
+        xTests(x);
+        yTests(y);
+        xarTests(xar);
+        yarTests(yar);
+        xarararTests(xararar);
+        yarararTests(yararar);
+        iarTests(iar);
+        iararTests(iarar);
+
+        yararar[0] = yarar;
+        yararar[0][0] = yar;
+        yararar[0][1] = yar;
+        yararar[0][0][0] = y;
+        yararar[0][0][1] = y;
+        yararar[0][0][2] = y;
+        yararar[0][1][0] = y;
+        yararar[0][1][1] = y;
+        yararar[0][1][2] = y;
+
+        String strForm;
+
+        String[][][][] multi1 = new String[2][3][2][1];
+        multi1[0] = new String[2][3][2];
+        multi1[0][1] = new String[3][2];
+        multi1[0][1][2] = new String[2];
+        multi1[0][1][2][1] = "HELLO-1";
+        strForm = Arrays.deepToString(multi1);
+
+        String[][][][][] multi2 = new String[5][2][3][2][1];
+        multi2[0] = new String[5][2][3][2];
+        multi2[0][1] = new String[5][2][3];
+        multi2[0][1][2] = new String[5][2];
+        multi2[0][1][2][1] = new String[5];
+        multi2[0][1][2][1][4] = "HELLO-2";
+        strForm = Arrays.deepToString(multi2);
+
+
+        String[][][][][][] multi3 = new String[2][5][2][3][2][1];
+        multi3[0] = new String[2][][][][];
+        multi3[0][1] = new String[3][][][];
+        multi3[0][1][2] = new String[2][][];
+        multi3[0][1][2][1] = new String[5][];
+        multi3[0][1][2][1][4] = new String[2];
+        multi3[0][1][2][1][4][1] = "HELLO-3";
+        strForm = Arrays.deepToString(multi3);
+
+        // build up pieces
+        String[][][][][][] multi4 = new String[1][][][][][];
+        multi4[0] = new String[2][][][][];
+        multi4[0][1] = new String[3][][][];
+        multi4[0][1][2] = new String[2][][];
+        multi4[0][1][2][1] = new String[5][];
+        multi4[0][1][2][1][4] = new String[2];
+        multi4[0][1][2][1][4][1] = "HELLO-4";
+        strForm = Arrays.deepToString(multi4);
+
+        /* this is expected to fail; 1073921584 * 4 overflows 32 bits */
+        try {
+            String[][][][][] multiX = new String[5][2][3][2][1073921584];
+            assert(false);
+        } catch (Error e) {
+            //System.out.println("  Got expected failure: " + e);
+        }
+
+    }
+
+    public static void run() {
+        Classes classes = new Classes();
+        MoreClasses more = new MoreClasses();
+        classes.checkCast(classes, more, null);
+
+        more.subFunc(true);
+        more.superFunc(false);
+        arrayInstance();
+    }
+}
+
+class MoreClasses extends Classes {
+    int mMore;
+
+    public MoreClasses() {}
+
+    public void subFunc(boolean wantSub) {
+        assert(wantSub);
+    }
+
+    public void superFunc(boolean wantSub) {
+        super.subFunc(wantSub);
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/Compare.java b/test/003-omnibus-opcodes/src/Compare.java
new file mode 100644 (file)
index 0000000..43a708a
--- /dev/null
@@ -0,0 +1,171 @@
+// Copyright 2008 The Android Open Source Project
+
+
+
+/**
+ * Test comparison operators.
+ */
+public class Compare {
+
+    /*
+     * Test the integer comparisons in various ways.
+     */
+    static void testIntCompare(int minus, int plus, int plus2, int zero) {
+        System.out.println("IntMath.testIntCompare");
+
+        if (minus > plus)
+            assert(false);
+        if (minus >= plus)
+            assert(false);
+        if (plus < minus)
+            assert(false);
+        if (plus <= minus)
+            assert(false);
+        if (plus == minus)
+            assert(false);
+        if (plus != plus2)
+            assert(false);
+
+        /* try a branch-taken */
+        if (plus != minus) {
+            assert(true);
+        } else {
+            assert(false);
+        }
+
+        if (minus > 0)
+            assert(false);
+        if (minus >= 0)
+            assert(false);
+        if (plus < 0)
+            assert(false);
+        if (plus <= 0)
+            assert(false);
+        if (plus == 0)
+            assert(false);
+        if (zero != 0)
+            assert(false);
+
+        if (zero == 0) {
+            assert(true);
+        } else {
+            assert(false);
+        }
+    }
+
+    /*
+     * Test cmp-long.
+     *
+     * minus=-5, alsoMinus=0xFFFFFFFF00000009, plus=4, alsoPlus=8
+     */
+    static void testLongCompare(long minus, long alsoMinus, long plus,
+        long alsoPlus) {
+
+        System.out.println("IntMath.testLongCompare");
+        if (minus > plus)
+            assert(false);
+        if (plus < minus)
+            assert(false);
+        if (plus == minus)
+            assert(false);
+
+        if (plus >= plus+1)
+            assert(false);
+        if (minus >= minus+1)
+            assert(false);
+
+        /* try a branch-taken */
+        if (plus != minus) {
+            assert(true);
+        } else {
+            assert(false);
+        }
+
+        /* compare when high words are equal but low words differ */
+        if (plus > alsoPlus)
+            assert(false);
+        if (alsoPlus < plus)
+            assert(false);
+        if (alsoPlus == plus)
+            assert(false);
+
+        /* high words are equal, low words have apparently different signs */
+        if (minus < alsoMinus)      // bug!
+            assert(false);
+        if (alsoMinus > minus)
+            assert(false);
+        if (alsoMinus == minus)
+            assert(false);
+    }
+
+    /*
+     * Test cmpl-float and cmpg-float.
+     */
+    static void testFloatCompare(float minus, float plus, float plus2,
+        float nan) {
+
+        System.out.println("IntMath.testFloatCompare");
+        if (minus > plus)
+            assert(false);
+        if (plus < minus)
+            assert(false);
+        if (plus == minus)
+            assert(false);
+        if (plus != plus2)
+            assert(false);
+
+        if (plus <= nan)
+            assert(false);
+        if (plus >= nan)
+            assert(false);
+        if (minus <= nan)
+            assert(false);
+        if (minus >= nan)
+            assert(false);
+        if (nan >= plus)
+            assert(false);
+        if (nan <= plus)
+            assert(false);
+
+        if (nan == nan)
+            assert(false);
+    }
+
+    static void testDoubleCompare(double minus, double plus, double plus2,
+        double nan) {
+
+        System.out.println("IntMath.testDoubleCompare");
+        if (minus > plus)
+            assert(false);
+        if (plus < minus)
+            assert(false);
+        if (plus == minus)
+            assert(false);
+        if (plus != plus2)
+            assert(false);
+
+        if (plus <= nan)
+            assert(false);
+        if (plus >= nan)
+            assert(false);
+        if (minus <= nan)
+            assert(false);
+        if (minus >= nan)
+            assert(false);
+        if (nan >= plus)
+            assert(false);
+        if (nan <= plus)
+            assert(false);
+
+        if (nan == nan)
+            assert(false);
+    }
+
+    public static void run() {
+        testIntCompare(-5, 4, 4, 0);
+        testLongCompare(-5L, -4294967287L, 4L, 8L);
+
+        testFloatCompare(-5.0f, 4.0f, 4.0f, (1.0f/0.0f) / (1.0f/0.0f));
+        testDoubleCompare(-5.0, 4.0, 4.0, (1.0/0.0) / (1.0/0.0));
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/FloatMath.java b/test/003-omnibus-opcodes/src/FloatMath.java
new file mode 100644 (file)
index 0000000..3c49402
--- /dev/null
@@ -0,0 +1,337 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Test arithmetic operations.
+ */
+public class FloatMath {
+
+    static void convTest() {
+        System.out.println("FloatMath.convTest");
+
+        float f;
+        double d;
+        int i;
+        long l;
+
+        /* float --> int */
+        f = 1234.5678f;
+        i = (int) f;
+        assert(i == 1234);
+
+        f = -1234.5678f;
+        i = (int) f;
+        assert(i == -1234);
+
+        /* float --> long */
+        f = 1238.5678f;
+        l = (long) f;
+        assert(l == 1238);
+
+        f = -1238.5678f;
+        l = (long) f;
+        assert(l == -1238);
+
+        /* float --> double */
+        f = 1238.5678f;
+        d = (double) f;
+        assert(d > 1238.567 && d < 1238.568);
+
+        /* double --> int */
+        d = 1234.5678;
+        i = (int) d;
+        assert(i == 1234);
+
+        d = -1234.5678;
+        i = (int) d;
+        assert(i == -1234);
+
+        /* double --> long */
+        d = 5678956789.0123;
+        l = (long) d;
+        assert(l == 5678956789L);
+
+        d = -5678956789.0123;
+        l = (long) d;
+        assert(l == -5678956789L);
+
+        /* double --> float */
+        d = 1238.5678;
+        f = (float) d;
+        assert(f > 1238.567 && f < 1238.568);
+
+        /* int --> long */
+        i = 7654;
+        l = (long) i;
+        assert(l == 7654L);
+
+        i = -7654;
+        l = (long) i;
+        assert(l == -7654L);
+
+        /* int --> float */
+        i = 1234;
+        f = (float) i;
+        assert(f > 1233.9f && f < 1234.1f);
+
+        i = -1234;
+        f = (float) i;
+        assert(f < -1233.9f && f > -1234.1f);
+
+        /* int --> double */
+        i = 1238;
+        d = (double) i;
+        assert(d > 1237.9f && d < 1238.1f);
+
+        i = -1238;
+        d = (double) i;
+        assert(d < -1237.9f && d > -1238.1f);
+
+        /* long --> int (with truncation) */
+        l = 5678956789L;
+        i = (int) l;
+        assert(i == 1383989493);
+
+        l = -5678956789L;
+        i = (int) l;
+        assert(i == -1383989493);
+
+        /* long --> float */
+        l = 5678956789L;
+        f = (float) l;
+        assert(f > 5.6789564E9 && f < 5.6789566E9);
+
+        l = -5678956789L;
+        f = (float) l;
+        assert(f < -5.6789564E9 && f > -5.6789566E9);
+
+        /* long --> double */
+        l = 6678956789L;
+        d = (double) l;
+        assert(d > 6.6789567E9 && d < 6.6789568E9);
+
+        l = -6678956789L;
+        d = (double) l;
+        assert(d < -6.6789567E9 && d > -6.6789568E9);
+    }
+
+    /*
+     * We pass in the arguments and return the results so the compiler
+     * doesn't do the math for us.
+     */
+    static float[] floatOperTest(float x, float y) {
+        System.out.println("FloatMath.floatOperTest");
+
+        float[] results = new float[9];
+
+        /* this seems to generate "op-float" instructions */
+        results[0] = x + y;
+        results[1] = x - y;
+        results[2] = x * y;
+        results[3] = x / y;
+        results[4] = x % -y;
+
+        /* this seems to generate "op-float/2addr" instructions */
+        results[8] = x + (((((x + y) - y) * y) / y) % y);
+
+        return results;
+    }
+    static void floatOperCheck(float[] results) {
+        assert(results[0] > 69996.99f && results[0] < 69997.01f);
+        assert(results[1] > 70002.99f && results[1] < 70003.01f);
+        assert(results[2] > -210000.01f && results[2] < -209999.99f);
+        assert(results[3] > -23333.34f && results[3] < -23333.32f);
+        assert(results[4] > 0.999f && results[4] < 1.001f);
+        assert(results[8] > 70000.99f && results[8] < 70001.01f);
+    }
+
+    /*
+     * We pass in the arguments and return the results so the compiler
+     * doesn't do the math for us.
+     */
+    static double[] doubleOperTest(double x, double y) {
+        System.out.println("FloatMath.doubleOperTest");
+
+        double[] results = new double[9];
+
+        /* this seems to generate "op-double" instructions */
+        results[0] = x + y;
+        results[1] = x - y;
+        results[2] = x * y;
+        results[3] = x / y;
+        results[4] = x % -y;
+
+        /* this seems to generate "op-double/2addr" instructions */
+        results[8] = x + (((((x + y) - y) * y) / y) % y);
+
+        return results;
+    }
+    static void doubleOperCheck(double[] results) {
+        assert(results[0] > 69996.99 && results[0] < 69997.01);
+        assert(results[1] > 70002.99 && results[1] < 70003.01);
+        assert(results[2] > -210000.01 && results[2] < -209999.99);
+        assert(results[3] > -23333.34 && results[3] < -23333.32);
+        assert(results[4] > 0.999 && results[4] < 1.001);
+        assert(results[8] > 70000.99 && results[8] < 70001.01);
+    }
+
+    /*
+     * Try to cause some unary operations.
+     */
+    static float unopTest(float f) {
+        f = -f;
+        return f;
+    }
+
+    static int[] convI(long l, float f, double d, float zero) {
+        int[] results = new int[6];
+        results[0] = (int) l;
+        results[1] = (int) f;
+        results[2] = (int) d;
+        results[3] = (int) (1.0f / zero);       // +inf
+        results[4] = (int) (-1.0f / zero);      // -inf
+        results[5] = (int) ((1.0f / zero) / (1.0f / zero)); // NaN
+        return results;
+    }
+    static void checkConvI(int[] results) {
+        System.out.println("FloatMath.checkConvI");
+        assert(results[0] == 0x44332211);
+        assert(results[1] == 123);
+        assert(results[2] == -3);
+        assert(results[3] == 0x7fffffff);
+        assert(results[4] == 0x80000000);
+        assert(results[5] == 0);
+    }
+
+    static long[] convL(int i, float f, double d, double zero) {
+        long[] results = new long[6];
+        results[0] = (long) i;
+        results[1] = (long) f;
+        results[2] = (long) d;
+        results[3] = (long) (1.0 / zero);       // +inf
+        results[4] = (long) (-1.0 / zero);      // -inf
+        results[5] = (long) ((1.0 / zero) / (1.0 / zero));  // NaN
+        return results;
+    }
+    static void checkConvL(long[] results) {
+        System.out.println("FloatMath.checkConvL");
+        assert(results[0] == 0xFFFFFFFF88776655L);
+        assert(results[1] == 123);
+        assert(results[2] == -3);
+        assert(results[3] == 0x7fffffffffffffffL);
+        assert(results[4] == 0x8000000000000000L);
+        assert(results[5] == 0);
+    }
+
+    static float[] convF(int i, long l, double d) {
+        float[] results = new float[3];
+        results[0] = (float) i;
+        results[1] = (float) l;
+        results[2] = (float) d;
+        return results;
+    }
+    static void checkConvF(float[] results) {
+        System.out.println("FloatMath.checkConvF");
+        // TODO: assert values
+        for (int i = 0; i < results.length; i++)
+            System.out.println(" " + i + ": " + results[i]);
+        System.out.println("-2.0054409E9, -8.6133031E18, -3.1415927");
+    }
+
+    static double[] convD(int i, long l, float f) {
+        double[] results = new double[3];
+        results[0] = (double) i;
+        results[1] = (double) l;
+        results[2] = (double) f;
+        return results;
+    }
+    static void checkConvD(double[] results) {
+        System.out.println("FloatMath.checkConvD");
+        // TODO: assert values
+        for (int i = 0; i < results.length; i++)
+            System.out.println(" " + i + ": " + results[i]);
+        System.out.println("-2.005440939E9, -8.6133032459203287E18, 123.4560012817382");
+    }
+
+    static void checkConsts() {
+        System.out.println("FloatMath.checkConsts");
+
+        float f = 10.0f;        // const/special
+        assert(f > 9.9 && f < 10.1);
+
+        double d = 10.0;        // const-wide/special
+        assert(d > 9.9 && d < 10.1);
+    }
+
+    /*
+     * Determine if two floating point numbers are approximately equal.
+     *
+     * (Assumes that floating point is generally working, so we can't use
+     * this for the first set of tests.)
+     */
+    static boolean approxEqual(float a, float b, float maxDelta) {
+        if (a > b)
+            return (a - b) < maxDelta;
+        else
+            return (b - a) < maxDelta;
+    }
+    static boolean approxEqual(double a, double b, double maxDelta) {
+        if (a > b)
+            return (a - b) < maxDelta;
+        else
+            return (b - a) < maxDelta;
+    }
+
+    /*
+     * Test some java.lang.Math functions.
+     *
+     * The method arguments are positive values.
+     */
+    static void jlmTests(float ff, double dd) {
+        System.out.println("FloatMath.jlmTests");
+
+        assert(approxEqual(Math.abs(ff), ff, 0.001f));
+        assert(approxEqual(Math.abs(-ff), ff, 0.001f));
+        assert(approxEqual(Math.min(ff, -5.0f), -5.0f, 0.001f));
+        assert(approxEqual(Math.max(ff, -5.0f), ff, 0.001f));
+
+        assert(approxEqual(Math.abs(dd), dd, 0.001));
+        assert(approxEqual(Math.abs(-dd), dd, 0.001));
+        assert(approxEqual(Math.min(dd, -5.0), -5.0, 0.001));
+        assert(approxEqual(Math.max(dd, -5.0), dd, 0.001));
+
+        double sq = Math.sqrt(dd);
+        assert(approxEqual(sq*sq, dd, 0.001));
+
+        assert(approxEqual(0.5403023058681398, Math.cos(1.0), 0.00000001));
+        assert(approxEqual(0.8414709848078965, Math.sin(1.0), 0.00000001));
+    }
+
+    public static void run() {
+        convTest();
+
+        float[] floatResults;
+        double[] doubleResults;
+        int[] intResults;
+        long[] longResults;
+
+        floatResults = floatOperTest(70000.0f, -3.0f);
+        floatOperCheck(floatResults);
+        doubleResults = doubleOperTest(70000.0, -3.0);
+        doubleOperCheck(doubleResults);
+
+        intResults = convI(0x8877665544332211L, 123.456f, -3.1415926535, 0.0f);
+        checkConvI(intResults);
+        longResults = convL(0x88776655, 123.456f, -3.1415926535, 0.0);
+        checkConvL(longResults);
+        floatResults = convF(0x88776655, 0x8877665544332211L, -3.1415926535);
+        checkConvF(floatResults);
+        doubleResults = convD(0x88776655, 0x8877665544332211L, 123.456f);
+        checkConvD(doubleResults);
+
+        unopTest(123.456f);
+
+        checkConsts();
+
+        jlmTests(3.14159f, 123456.78987654321);
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/Goto.java b/test/003-omnibus-opcodes/src/Goto.java
new file mode 100644 (file)
index 0000000..d56ceae
--- /dev/null
@@ -0,0 +1,2408 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/**
+ * Try to cause some gotos.
+ */
+class Goto {
+    static int filler(int i) {
+        return i+1;
+    }
+
+    static int smallGoto(boolean which) {
+        System.out.println("Goto.smallGoto");
+
+        int i = 0;
+
+        if (which) {
+            i += filler(i);
+        } else {
+            i -= filler(i);
+        }
+
+        return i;
+    }
+
+    static int mediumGoto(boolean which) {
+        System.out.println("Goto.mediumGoto");
+
+        int i = 0;
+
+        if (which) {
+            i += filler(i);
+        } else {
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+        }
+
+        return i;
+    }
+
+    static int bigGoto(boolean which) {
+        System.out.println("Goto.bigGoto");
+
+        int i = 0;
+
+        if (which) {
+            i += filler(i);
+        } else {
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+            i -= filler(i);  i -= filler(i);  i -= filler(i);  i -= filler(i);
+        }
+
+        return i;
+    }
+
+    public static void run() {
+        smallGoto(false);
+        smallGoto(true);
+        mediumGoto(false);
+        mediumGoto(true);
+        bigGoto(false);
+        bigGoto(true);
+    }
+};
diff --git a/test/003-omnibus-opcodes/src/InstField.java b/test/003-omnibus-opcodes/src/InstField.java
new file mode 100644 (file)
index 0000000..80b95ab
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+public class InstField {
+    public boolean mBoolean1, mBoolean2;
+    public byte mByte1, mByte2;
+    public char mChar1, mChar2;
+    public short mShort1, mShort2;
+    public int mInt1, mInt2;
+    public float mFloat1, mFloat2;
+    public long mLong1, mLong2;
+    public double mDouble1, mDouble2;
+    public volatile long mVolatileLong1, mVolatileLong2;
+
+    public void run() {
+        assignFields();
+        checkFields();
+        InstField.nullCheck(null);
+    }
+
+    /*
+     * Check access to instance fields through a null pointer.
+     */
+    static public void nullCheck(InstField nully) {
+        System.out.println("InstField.nullCheck");
+        try {
+            int x = nully.mInt1;
+            assert(false);
+        } catch (NullPointerException npe) {
+            // good
+        }
+        try {
+            long l = nully.mLong1;
+            assert(false);
+        } catch (NullPointerException npe) {
+            // good
+        }
+        try {
+            nully.mInt1 = 5;
+            assert(false);
+        } catch (NullPointerException npe) {
+            // good
+        }
+        try {
+            nully.mLong1 = 17L;
+            assert(false);
+        } catch (NullPointerException npe) {
+            // good
+        }
+    }
+
+    public void assignFields() {
+        System.out.println("InstField assign...");
+        mBoolean1 = true;
+        mBoolean2 = false;
+        mByte1 = 127;
+        mByte2 = -128;
+        mChar1 = 32767;
+        mChar2 = 65535;
+        mShort1 = 32767;
+        mShort2 = -32768;
+        mInt1 = 65537;
+        mInt2 = -65537;
+        mFloat1 = 3.1415f;
+        mFloat2 = -1.0f / 0.0f;                // -inf
+        mLong1 = 1234605616436508552L;     // 0x1122334455667788
+        mLong2 = -1234605616436508552L;
+        mDouble1 = 3.1415926535;
+        mDouble2 = 1.0 / 0.0;               // +inf
+        mVolatileLong1 = mLong1 - 1;
+        mVolatileLong2 = mLong2 + 1;
+    }
+
+    public void checkFields() {
+        System.out.println("InstField check...");
+        assert(mBoolean1);
+        assert(!mBoolean2);
+        assert(mByte1 == 127);
+        assert(mByte2 == -128);
+        assert(mChar1 == 32767);
+        assert(mChar2 == 65535);
+        assert(mShort1 == 32767);
+        assert(mShort2 == -32768);
+        assert(mInt1 == 65537);
+        assert(mInt2 == -65537);
+        assert(mFloat1 > 3.141f && mFloat1 < 3.142f);
+        assert(mFloat2 < mFloat1);
+        assert(mLong1 == 1234605616436508552L);
+        assert(mLong2 == -1234605616436508552L);
+        assert(mDouble1 > 3.141592653 && mDouble1 < 3.141592654);
+        assert(mDouble2 > mDouble1);
+        assert(mVolatileLong1 == 1234605616436508551L);
+        assert(mVolatileLong2 == -1234605616436508551L);
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/IntMath.java b/test/003-omnibus-opcodes/src/IntMath.java
new file mode 100644 (file)
index 0000000..89194de
--- /dev/null
@@ -0,0 +1,492 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Test arithmetic operations.
+ */
+public class IntMath {
+
+    static void shiftTest1() {
+        System.out.println("IntMath.shiftTest1");
+
+        final int[] mBytes = {
+            0x11, 0x22, 0x33, 0x44, 0x88, 0x99, 0xaa, 0xbb
+        };
+        long l;
+        int i1, i2;
+
+        i1 = mBytes[0] | mBytes[1] << 8 | mBytes[2] << 16 | mBytes[3] << 24;
+        i2 = mBytes[4] | mBytes[5] << 8 | mBytes[6] << 16 | mBytes[7] << 24;
+        l = i1 | ((long)i2 << 32);
+
+        assert(i1 == 0x44332211);
+        assert(i2 == 0xbbaa9988);
+        assert(l == 0xbbaa998844332211L);
+
+        l = (long)mBytes[0]
+            | (long)mBytes[1] << 8
+            | (long)mBytes[2] << 16
+            | (long)mBytes[3] << 24
+            | (long)mBytes[4] << 32
+            | (long)mBytes[5] << 40
+            | (long)mBytes[6] << 48
+            | (long)mBytes[7] << 56;
+
+        assert(l == 0xbbaa998844332211L);
+    }
+
+    static void shiftTest2() {
+        System.out.println("IntMath.shiftTest2");
+
+        long    a = 0x11;
+        long    b = 0x22;
+        long    c = 0x33;
+        long    d = 0x44;
+        long    e = 0x55;
+        long    f = 0x66;
+        long    g = 0x77;
+        long    h = 0x88;
+
+        long    result = ((a << 56) | (b << 48) | (c << 40) | (d << 32) |
+                         (e << 24) | (f << 16) | (g <<  8) | h);
+
+        assert(result == 0x1122334455667788L);
+    }
+
+    static void unsignedShiftTest() {
+        System.out.println("IntMath.unsignedShiftTest");
+
+        byte b = -4;
+        short s = -4;
+        char c = 0xfffc;
+        int i = -4;
+
+        b >>>= 4;
+        s >>>= 4;
+        c >>>= 4;
+        i >>>= 4;
+
+        assert((int) b == -1);
+        assert((int) s == -1);
+        assert((int) c == 0x0fff);
+        assert(i == 268435455);
+    }
+
+    static void convTest() {
+        System.out.println("IntMath.convTest");
+
+        float f;
+        double d;
+        int i;
+        long l;
+
+        /* int --> long */
+        i = 7654;
+        l = (long) i;
+        assert(l == 7654L);
+
+        i = -7654;
+        l = (long) i;
+        assert(l == -7654L);
+
+        /* long --> int (with truncation) */
+        l = 5678956789L;
+        i = (int) l;
+        assert(i == 1383989493);
+
+        l = -5678956789L;
+        i = (int) l;
+        assert(i == -1383989493);
+    }
+
+    static void charSubTest() {
+        System.out.println("IntMath.charSubTest");
+
+        char char1 = 0x00e9;
+        char char2 = 0xffff;
+        int i;
+
+        /* chars are unsigned-expanded to ints before subtraction */
+        i = char1 - char2;
+        assert(i == 0xffff00ea);
+    }
+
+    /*
+     * We pass in the arguments and return the results so the compiler
+     * doesn't do the math for us.  (x=70000, y=-3)
+     */
+    static int[] intOperTest(int x, int y) {
+        System.out.println("IntMath.intOperTest");
+
+        int[] results = new int[10];
+
+        /* this seems to generate "op-int" instructions */
+        results[0] = x + y;
+        results[1] = x - y;
+        results[2] = x * y;
+        results[3] = x * x;
+        results[4] = x / y;
+        results[5] = x % -y;
+        results[6] = x & y;
+        results[7] = x | y;
+        results[8] = x ^ y;
+
+        /* this seems to generate "op-int/2addr" instructions */
+        results[9] = x + ((((((((x + y) - y) * y) / y) % y) & y) | y) ^ y);
+
+        return results;
+    }
+    static void intOperCheck(int[] results) {
+        System.out.println("IntMath.intOperCheck");
+
+        /* check this edge case while we're here (div-int/2addr) */
+        int minInt = -2147483648;
+        int negOne = -results[5];
+        int plusOne = 1;
+        int result = (((minInt + plusOne) - plusOne) / negOne) / negOne;
+        assert(result == minInt);
+
+        assert(results[0] == 69997);
+        assert(results[1] == 70003);
+        assert(results[2] == -210000);
+        assert(results[3] == 605032704);    // overflow / truncate
+        assert(results[4] == -23333);
+        assert(results[5] == 1);
+        assert(results[6] == 70000);
+        assert(results[7] == -3);
+        assert(results[8] == -70003);
+        assert(results[9] == 70000);
+    }
+
+    /*
+     * More operations, this time with 16-bit constants.  (x=77777)
+     */
+    static int[] lit16Test(int x) {
+        System.out.println("IntMath.lit16Test");
+
+        int[] results = new int[8];
+
+        /* try to generate op-int/lit16" instructions */
+        results[0] = x + 1000;
+        results[1] = 1000 - x;
+        results[2] = x * 1000;
+        results[3] = x / 1000;
+        results[4] = x % 1000;
+        results[5] = x & 1000;
+        results[6] = x | -1000;
+        results[7] = x ^ -1000;
+        return results;
+    }
+    static void lit16Check(int[] results) {
+        assert(results[0] == 78777);
+        assert(results[1] == -76777);
+        assert(results[2] == 77777000);
+        assert(results[3] == 77);
+        assert(results[4] == 777);
+        assert(results[5] == 960);
+        assert(results[6] == -39);
+        assert(results[7] == -76855);
+    }
+
+    /*
+     * More operations, this time with 8-bit constants.  (x=-55555)
+     */
+    static int[] lit8Test(int x) {
+        System.out.println("IntMath.lit8Test");
+
+        int[] results = new int[8];
+
+        /* try to generate op-int/lit8" instructions */
+        results[0] = x + 10;
+        results[1] = 10 - x;
+        results[2] = x * 10;
+        results[3] = x / 10;
+        results[4] = x % 10;
+        results[5] = x & 10;
+        results[6] = x | -10;
+        results[7] = x ^ -10;
+        return results;
+    }
+    static void lit8Check(int[] results) {
+        //for (int i = 0; i < results.length; i++)
+        //    System.out.println(" " + i + ": " + results[i]);
+
+        /* check this edge case while we're here (div-int/lit8) */
+        int minInt = -2147483648;
+        int result = minInt / -1;
+        assert(result == minInt);
+
+        assert(results[0] == -55545);
+        assert(results[1] == 55565);
+        assert(results[2] == -555550);
+        assert(results[3] == -5555);
+        assert(results[4] == -5);
+        assert(results[5] == 8);
+        assert(results[6] == -1);
+        assert(results[7] == 55563);
+    }
+
+
+    /*
+     * Shift some data.  (value=0xff00aa01, dist=8)
+     */
+    static int[] intShiftTest(int value, int dist) {
+        System.out.println("IntMath.intShiftTest");
+
+        int results[] = new int[4];
+
+        results[0] = value << dist;
+        results[1] = value >> dist;
+        results[2] = value >>> dist;
+
+        results[3] = (((value << dist) >> dist) >>> dist) << dist;
+        return results;
+    }
+    static void intShiftCheck(int[] results) {
+        System.out.println("IntMath.intShiftCheck");
+
+        assert(results[0] == 0x00aa0100);
+        assert(results[1] == 0xffff00aa);
+        assert(results[2] == 0x00ff00aa);
+        assert(results[3] == 0xaa00);
+    }
+
+    /*
+     * We pass in the arguments and return the results so the compiler
+     * doesn't do the math for us.  (x=70000000000, y=-3)
+     */
+    static long[] longOperTest(long x, long y) {
+        System.out.println("IntMath.longOperTest");
+
+        long[] results = new long[10];
+
+        /* this seems to generate "op-long" instructions */
+        results[0] = x + y;
+        results[1] = x - y;
+        results[2] = x * y;
+        results[3] = x * x;
+        results[4] = x / y;
+        results[5] = x % -y;
+        results[6] = x & y;
+        results[7] = x | y;
+        results[8] = x ^ y;
+
+        /* this seems to generate "op-long/2addr" instructions */
+        results[9] = x + ((((((((x + y) - y) * y) / y) % y) & y) | y) ^ y);
+
+        return results;
+    }
+    static void longOperCheck(long[] results) {
+        System.out.println("IntMath.longOperCheck");
+
+        /* check this edge case while we're here (div-long/2addr) */
+        long minLong = -9223372036854775808L;
+        long negOne = -results[5];
+        long plusOne = 1;
+        long result = (((minLong + plusOne) - plusOne) / negOne) / negOne;
+        assert(result == minLong);
+
+        assert(results[0] == 69999999997L);
+        assert(results[1] == 70000000003L);
+        assert(results[2] == -210000000000L);
+        assert(results[3] == -6833923606740729856L);    // overflow
+        assert(results[4] == -23333333333L);
+        assert(results[5] == 1);
+        assert(results[6] == 70000000000L);
+        assert(results[7] == -3);
+        assert(results[8] == -70000000003L);
+        assert(results[9] == 70000000000L);
+
+        assert(results.length == 10);
+    }
+
+    /*
+     * Shift some data.  (value=0xd5aa96deff00aa01, dist=8)
+     */
+    static long[] longShiftTest(long value, int dist) {
+        System.out.println("IntMath.longShiftTest");
+
+        long results[] = new long[4];
+
+        results[0] = value << dist;
+        results[1] = value >> dist;
+        results[2] = value >>> dist;
+
+        results[3] = (((value << dist) >> dist) >>> dist) << dist;
+        return results;
+    }
+    static long longShiftCheck(long[] results) {
+        System.out.println("IntMath.longShiftCheck");
+
+        assert(results[0] == 0x96deff00aa010000L);
+        assert(results[1] == 0xffffd5aa96deff00L);
+        assert(results[2] == 0x0000d5aa96deff00L);
+        assert(results[3] == 0xffff96deff000000L);
+
+        assert(results.length == 4);
+
+        return results[0];      // test return-long
+    }
+
+
+    /*
+     * Try to cause some unary operations.
+     */
+    static int unopTest(int x) {
+        x = -x;
+        x ^= 0xffffffff;
+        return x;
+    }
+    static void unopCheck(int result) {
+        assert(result == 37);
+    }
+
+    static class Shorty {
+        public short mShort;
+        public char mChar;
+        public byte mByte;
+    };
+
+    /*
+     * Truncate an int.
+     */
+    static Shorty truncateTest(int x) {
+        System.out.println("IntMath.truncateTest");
+        Shorty shorts = new Shorty();
+
+        shorts.mShort = (short) x;
+        shorts.mChar = (char) x;
+        shorts.mByte = (byte) x;
+        return shorts;
+    }
+    static void truncateCheck(Shorty shorts) {
+        assert(shorts.mShort == -5597);     // 0xea23
+        assert(shorts.mChar == 59939);      // 0xea23
+        assert(shorts.mByte == 35);         // 0x23
+    }
+
+    /*
+     * Verify that we get a divide-by-zero exception.
+     */
+    static void divideByZero(int z) {
+        System.out.println("IntMath.divideByZero");
+
+        try {
+            int x = 100 / z;
+            assert(false);
+        } catch (ArithmeticException ae) {
+        }
+
+        try {
+            int x = 100 % z;
+            assert(false);
+        } catch (ArithmeticException ae) {
+        }
+
+        try {
+            long x = 100L / z;
+            assert(false);
+        } catch (ArithmeticException ae) {
+        }
+
+        try {
+            long x = 100L % z;
+            assert(false);
+        } catch (ArithmeticException ae) {
+        }
+    }
+
+    /*
+     * Check an edge condition: dividing the most-negative integer by -1
+     * returns the most-negative integer, and doesn't cause an exception.
+     *
+     * Pass in -1, -1L.
+     */
+    static void bigDivideOverflow(int idiv, long ldiv) {
+        System.out.println("IntMath.bigDivideOverflow");
+        int mostNegInt = (int) 0x80000000;
+        long mostNegLong = (long) 0x8000000000000000L;
+
+        int intDivResult = mostNegInt / idiv;
+        int intModResult = mostNegInt % idiv;
+        long longDivResult = mostNegLong / ldiv;
+        long longModResult = mostNegLong % ldiv;
+
+        assert(intDivResult == mostNegInt);
+        assert(intModResult == 0);
+        assert(longDivResult == mostNegLong);
+        assert(longModResult == 0);
+    }
+
+    /*
+     * Check "const" instructions.  We use negative values to ensure that
+     * sign-extension is happening.
+     */
+    static void checkConsts(byte small, short medium, int large, long huge) {
+        System.out.println("IntMath.checkConsts");
+
+        assert(small == 1);                     // const/4
+        assert(medium == -256);                 // const/16
+        assert(medium == -256L);                // const-wide/16
+        assert(large == -88888);                // const
+        assert(large == -88888L);               // const-wide/32
+        assert(huge == 0x9922334455667788L);    // const-wide
+    }
+
+    /*
+     * Test some java.lang.Math functions.
+     *
+     * The method arguments are positive values.
+     */
+    static void jlmTests(int ii, long ll) {
+        System.out.println("IntMath.jlmTests");
+
+        assert(Math.abs(ii) == ii);
+        assert(Math.abs(-ii) == ii);
+        assert(Math.min(ii, -5) == -5);
+        assert(Math.max(ii, -5) == ii);
+
+        assert(Math.abs(ll) == ll);
+        assert(Math.abs(-ll) == ll);
+        assert(Math.min(ll, -5L) == -5L);
+        assert(Math.max(ll, -5L) == ll);
+    }
+
+    public static void run() {
+        shiftTest1();
+        shiftTest2();
+        unsignedShiftTest();
+        convTest();
+        charSubTest();
+
+        int[] intResults;
+        long[] longResults;
+
+        intResults = intOperTest(70000, -3);
+        intOperCheck(intResults);
+        longResults = longOperTest(70000000000L, -3L);
+        longOperCheck(longResults);
+
+        intResults = lit16Test(77777);
+        lit16Check(intResults);
+        intResults = lit8Test(-55555);
+        lit8Check(intResults);
+
+        intResults = intShiftTest(0xff00aa01, 8);
+        intShiftCheck(intResults);
+        longResults = longShiftTest(0xd5aa96deff00aa01L, 16);
+        long longRet = longShiftCheck(longResults);
+        assert(longRet == 0x96deff00aa010000L);
+
+        Shorty shorts = truncateTest(-16717277);    // 0xff00ea23
+        truncateCheck(shorts);
+
+        divideByZero(0);
+        bigDivideOverflow(-1, -1L);
+
+        checkConsts((byte) 1, (short) -256, -88888, 0x9922334455667788L);
+
+        unopCheck(unopTest(38));
+
+        jlmTests(12345, 0x1122334455667788L);
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/InternedString.java b/test/003-omnibus-opcodes/src/InternedString.java
new file mode 100644 (file)
index 0000000..4baab0c
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+import java.lang.ref.*;
+
+public class InternedString {
+    public static final String CONST = "Class InternedString";
+
+    public static void run() {
+        System.out.println("InternedString.run");
+        testImmortalInternedString();
+        testDeadInternedString();
+    }
+
+    private static void testDeadInternedString() {
+        String s = "blah";
+        s = s + s;
+        WeakReference strRef = new WeakReference<String>(s.intern());
+        // Kill s, otherwise the string object is still accessible from root set
+        s = CONST;
+        System.gc();
+        // "blahblah" should disappear from the intern list
+        assert(strRef.get() == null);
+    }
+
+    private static void testImmortalInternedString() {
+        WeakReference strRef = new WeakReference<String>(CONST.intern());
+        System.gc();
+        // Class constant string should be entered to the interned table when
+        // loaded
+        assert(CONST == CONST.intern());
+        // and it should survive the gc
+        assert(strRef.get() != null);
+
+        String s = CONST;
+        // "Class InternedString" should remain on the intern list
+        strRef = new WeakReference<String>(s.intern());
+        // Kill s, otherwise the string object is still accessible from root set
+        s = "";
+        System.gc();
+        assert(strRef.get() == CONST);
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/Main.java b/test/003-omnibus-opcodes/src/Main.java
new file mode 100644 (file)
index 0000000..fb39d76
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/**
+ * Dalvik instruction exerciser.
+ */
+public class Main {
+    /*
+     * Start up.
+     */
+    public static void main(String[] args) {
+        boolean assertEnabled = false;
+        assert assertEnabled = true;
+        if (!assertEnabled) {
+            System.out.println("FAIL: assert doesn't work (specify '-ea')\n");
+            throw new RuntimeException();
+        } else {
+            System.out.println("(assertions are enabled)");
+        }
+
+        Main main = new Main();
+        main.run();
+
+        /* run through the heap to see if we trashed something */
+        System.gc();
+
+        System.out.println("Done!");
+    }
+
+    public void run() {
+        InstField instField = new InstField();
+        instField.run();
+
+        StaticField.run();
+
+        IntMath.run();
+        FloatMath.run();
+        Compare.run();
+
+        Monitor.run();
+        Switch.run();
+        Array.run();
+        Classes.run();
+        Goto.run();
+        MethodCall.run();
+        Throw.run();
+
+        try {
+            UnresTest1.run();
+        } catch (VerifyError ve) {
+            System.out.println("Caught: " + ve);
+        }
+        try {
+            UnresTest1.run();
+        } catch (VerifyError ve) {
+            System.out.println("Caught (retry): " + ve);
+        }
+
+        try {
+            UnresTest2.run();
+        } catch (VerifyError ve) {
+            System.out.println("Caught: " + ve);
+        } catch (NoClassDefFoundError ncdfe) {
+            /* UnresClass can cause desktop Java to freak out */
+            System.out.println("NOTE: UnresTest2 not available");
+        }
+        InternedString.run();
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/MethodCall.java b/test/003-omnibus-opcodes/src/MethodCall.java
new file mode 100644 (file)
index 0000000..f89194b
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/**
+ * Try different kinds of method calls.
+ */
+public class MethodCall extends MethodCallBase {
+    MethodCall() {
+        super();
+        System.out.println("  MethodCall ctor");
+    }
+
+    /* overridden method */
+    int tryThing() {
+        int val = super.tryThing();
+        assert(val == 7);
+        return val;
+    }
+
+    /* do-nothing private instance method */
+    private void directly() {}
+
+    /*
+     * Function with many arguments.
+     */
+    static void manyArgs(int a0, long a1, int a2, long a3, int a4, long a5,
+        int a6, int a7, double a8, float a9, double a10, short a11, int a12,
+        char a13, int a14, int a15, byte a16, boolean a17, int a18, int a19,
+        long a20, long a21, int a22, int a23, int a24, int a25, int a26,
+        String[][] a27, String[] a28, String a29)
+    {
+        System.out.println("MethodCalls.manyArgs");
+        assert(a0 == 0);
+        assert(a9 > 8.99 && a9 < 9.01);
+        assert(a16 == -16);
+        assert(a25 == 25);
+        assert(a29.equals("twenty nine"));
+    }
+
+    public static void run() {
+        MethodCall inst = new MethodCall();
+
+        MethodCallBase base = inst;
+        base.tryThing();
+        inst.tryThing();
+
+        inst = null;
+        try {
+            inst.directly();
+            assert(false);
+        } catch (NullPointerException npe) {
+            // good
+        }
+
+        manyArgs(0, 1L, 2, 3L, 4, 5L, 6, 7, 8.0, 9.0f, 10.0, (short)11, 12,
+            (char)13, 14, 15, (byte)-16, true, 18, 19, 20L, 21L, 22, 23, 24,
+            25, 26, null, null, "twenty nine");
+    }
+}
+
+class MethodCallBase {
+    MethodCallBase() {
+        System.out.println("  MethodCallBase ctor");
+    }
+
+    int tryThing() {
+        return 7;
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/Monitor.java b/test/003-omnibus-opcodes/src/Monitor.java
new file mode 100644 (file)
index 0000000..66d7c65
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright 2008 The Android Open Source Project
+
+
+
+/**
+ * Exercise monitors.
+ */
+public class Monitor {
+    public static int mVal = 0;
+
+    public synchronized void subTest() {
+        Object obj = new Object();
+        synchronized (obj) {
+            mVal++;
+            obj = null;     // does NOT cause a failure on exit
+            assert(obj == null);
+        }
+    }
+
+
+    public static void run() {
+        System.out.println("Monitor.run");
+
+        Object obj = null;
+
+        try {
+            synchronized (obj) {
+                mVal++;
+            }
+            assert(false);
+        } catch (NullPointerException npe) {
+            /* expected */
+        }
+
+        obj = new Object();
+        synchronized (obj) {
+            mVal++;
+        }
+
+        new Monitor().subTest();
+
+        assert(mVal == 2);
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/StaticField.java b/test/003-omnibus-opcodes/src/StaticField.java
new file mode 100644 (file)
index 0000000..7ccdd7e
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+public class StaticField {
+    public static boolean mBoolean1, mBoolean2;
+    public static byte mByte1, mByte2;
+    public static char mChar1, mChar2;
+    public static short mShort1, mShort2;
+    public static int mInt1, mInt2;
+    public static float mFloat1, mFloat2;
+    public static long mLong1, mLong2;
+    public static double mDouble1, mDouble2;
+    public static volatile long mVolatileLong1, mVolatileLong2;
+
+    public static void run() {
+        assignFields();
+        checkFields();
+    }
+
+    public static void assignFields() {
+        System.out.println("StaticField assign...");
+        mBoolean1 = true;
+        mBoolean2 = false;
+        mByte1 = 127;
+        mByte2 = -128;
+        mChar1 = 32767;
+        mChar2 = 65535;
+        mShort1 = 32767;
+        mShort2 = -32768;
+        mInt1 = 65537;
+        mInt2 = -65537;
+        mFloat1 = 3.1415f;
+        mFloat2 = -1.0f / 0.0f;                // -inf
+        mLong1 = 1234605616436508552L;     // 0x1122334455667788
+        mLong2 = -1234605616436508552L;
+        mDouble1 = 3.1415926535;
+        mDouble2 = 1.0 / 0.0;               // +inf
+        mVolatileLong1 = mLong1 - 1;
+        mVolatileLong2 = mLong2 + 1;
+    }
+
+    public static void checkFields() {
+        System.out.println("StaticField check...");
+        assert(mBoolean1);
+        assert(!mBoolean2);
+        assert(mByte1 == 127);
+        assert(mByte2 == -128);
+        assert(mChar1 == 32767);
+        assert(mChar2 == 65535);
+        assert(mShort1 == 32767);
+        assert(mShort2 == -32768);
+        assert(mInt1 == 65537);
+        assert(mInt2 == -65537);
+        assert(mFloat1 > 3.141f && mFloat2 < 3.142f);
+        assert(mFloat2 < mFloat1);
+        assert(mLong1 == 1234605616436508552L);
+        assert(mLong2 == -1234605616436508552L);
+        assert(mDouble1 > 3.141592653 && mDouble1 < 3.141592654);
+        assert(mDouble2 > mDouble1);
+        assert(mVolatileLong1 == 1234605616436508551L);
+        assert(mVolatileLong2 == -1234605616436508551L);
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/Switch.java b/test/003-omnibus-opcodes/src/Switch.java
new file mode 100644 (file)
index 0000000..67c82b0
--- /dev/null
@@ -0,0 +1,62 @@
+public class Switch {
+    /**
+     * Test switch() blocks
+     */
+    private static void testSwitch() {
+        System.out.println("Switch.testSwitch");
+
+        int a = 1;
+
+        switch (a) {
+            case -1: assert(false); break;
+            case 0: assert(false); break;
+            case 1: /*correct*/ break;
+            case 2: assert(false); break;
+            case 3: assert(false); break;
+            case 4: assert(false); break;
+            default: assert(false); break;
+        }
+        switch (a) {
+            case 3: assert(false); break;
+            case 4: assert(false); break;
+            default: /*correct*/ break;
+        }
+
+        a = 0x12345678;
+
+        switch (a) {
+            case 0x12345678: /*correct*/ break;
+            case 0x12345679: assert(false); break;
+            default: assert(false); break;
+        }
+        switch (a) {
+            case 57: assert(false); break;
+            case -6: assert(false); break;
+            case 0x12345678: /*correct*/ break;
+            case 22: assert(false); break;
+            case 3: assert(false); break;
+            default: assert(false); break;
+        }
+        switch (a) {
+            case -6: assert(false); break;
+            case 3: assert(false); break;
+            default: /*correct*/ break;
+        }
+
+        a = -5;
+        switch (a) {
+            case 12: assert(false); break;
+            case -5: /*correct*/ break;
+            case 0: assert(false); break;
+            default: assert(false); break;
+        }
+
+        switch (a) {
+            default: /*correct*/ break;
+        }
+    }
+
+    public static void run() {
+        testSwitch();
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/Throw.java b/test/003-omnibus-opcodes/src/Throw.java
new file mode 100644 (file)
index 0000000..91ee6dd
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/**
+ * Test exception throwing.
+ */
+public class Throw {
+    public void throwNullPointerException() {
+        throw new NullPointerException("npe!");
+    }
+
+    public void throwArithmeticException() {
+        throw new ArithmeticException();
+    }
+
+    public void one() {
+        System.out.println("Throw.one");
+        try {
+            throwNullPointerException();
+            assert(false);
+        } catch (Exception ex) {
+            // good
+            return;
+        }
+
+        assert(false);
+    }
+
+    public void twoA() {
+        System.out.println("Throw.twoA");
+        boolean gotN = false;
+        boolean gotA = false;
+        boolean gotWeird = false;
+
+        try {
+            try {
+                throwArithmeticException();
+                gotWeird = true;
+            } catch (ArithmeticException ae) {
+                gotA = true;
+            }
+        } catch (NullPointerException npe) {
+            gotN = true;
+        }
+
+        assert(gotA);
+        assert(!gotN);
+        assert(!gotWeird);
+    }
+
+    public void twoN() {
+        System.out.println("Throw.twoN");
+        boolean gotN = false;
+        boolean gotA = false;
+        boolean gotWeird = false;
+
+        try {
+            try {
+                throwNullPointerException();
+                gotWeird = true;
+            } catch (ArithmeticException ae) {
+                gotA = true;
+            }
+        } catch (NullPointerException npe) {
+            gotN = true;
+        }
+
+        assert(!gotA);
+        assert(gotN);
+        assert(!gotWeird);
+    }
+
+    public void rethrow() {
+        System.out.println("Throw.rethrow");
+        boolean caught = false;
+        boolean lly = false;
+        boolean second = false;
+
+        try {
+            try {
+                throwNullPointerException();
+                assert(false);
+            } catch (Exception ex) {
+                if (ex instanceof ArithmeticException) {
+                    assert(false);
+                }
+                if (ex instanceof NullPointerException) {
+                    caught = true;
+                    throw (NullPointerException) ex;
+                }
+            } finally {
+                lly = true;
+            }
+        } catch (Exception ex) {
+            second = true;
+        }
+
+        assert(caught);
+        assert(lly);
+        assert(second);
+    }
+
+    public static void run() {
+        Throw th = new Throw();
+
+        th.one();
+        th.twoA();
+        th.twoN();
+        th.rethrow();
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/UnresClass.java b/test/003-omnibus-opcodes/src/UnresClass.java
new file mode 100644 (file)
index 0000000..52b3d4f
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * Unresolved class.
+ *
+ * "happy" version.
+ */
+
+public class UnresClass {
+    int foo;
+}
diff --git a/test/003-omnibus-opcodes/src/UnresStuff.java b/test/003-omnibus-opcodes/src/UnresStuff.java
new file mode 100644 (file)
index 0000000..1d2a556
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Unresolved classes / fields / methods in a resolved class.
+ *
+ * "happy" version.
+ */
+
+public class UnresStuff {
+    public int instField;
+
+    public static int staticField;
+
+    public double wideInstField;
+    public static double wideStaticField;
+
+    public void virtualMethod() {
+        System.out.println("unres!");
+    }
+
+    public static void staticMethod() {
+        System.out.println("unres!");
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/UnresTest1.java b/test/003-omnibus-opcodes/src/UnresTest1.java
new file mode 100644 (file)
index 0000000..5a80a7a
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Test failure to resolve class members.
+ */
+class UnresTest1 {
+    public static void run() {
+        System.out.println("UnresTest1...");
+
+        UnresStuff stuff = new UnresStuff();
+        try {
+            int x = stuff.instField;
+            assert(false);
+        } catch (NoSuchFieldError nsfe) {
+            // good
+        }
+        try {       // hit the same one a second time
+            int x = stuff.instField;
+            assert(false);
+        } catch (NoSuchFieldError nsfe) {
+            // good
+        }
+        try {
+            stuff.instField = 5;
+            assert(false);
+        } catch (NoSuchFieldError nsfe) {
+            // good
+        }
+
+        try {
+            double d = stuff.wideInstField;
+            assert(false);
+        } catch (NoSuchFieldError nsfe) {
+            // good
+        }
+        try {
+            stuff.wideInstField = 0.0;
+            assert(false);
+        } catch (NoSuchFieldError nsfe) {
+            // good
+        }
+
+        try {
+            int y = UnresStuff.staticField;
+            assert(false);
+        } catch (NoSuchFieldError nsfe) {
+            // good
+        }
+        try {
+            UnresStuff.staticField = 17;
+            assert(false);
+        } catch (NoSuchFieldError nsfe) {
+            // good
+        }
+
+        try {
+            double d = UnresStuff.wideStaticField;
+            assert(false);
+        } catch (NoSuchFieldError nsfe) {
+            // good
+        }
+        try {
+            UnresStuff.wideStaticField = 1.0;
+            assert(false);
+        } catch (NoSuchFieldError nsfe) {
+            // good
+        }
+
+        try {
+            stuff.virtualMethod();
+            assert(false);
+        } catch (NoSuchMethodError nsfe) {
+            // good
+        }
+        try {
+            UnresStuff.staticMethod();
+            assert(false);
+        } catch (NoSuchMethodError nsfe) {
+            // good
+        }
+    }
+}
diff --git a/test/003-omnibus-opcodes/src/UnresTest2.java b/test/003-omnibus-opcodes/src/UnresTest2.java
new file mode 100644 (file)
index 0000000..768be8f
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Test failure to resolve classes.
+ */
+class UnresTest2 {
+    /*
+     * Try check-cast and instance-of.
+     */
+    static boolean checkCasts(Object obj) {
+        boolean foo = false;
+
+        try {
+            UnresClass un = (UnresClass) obj;
+            assert(false);
+        } catch (NoClassDefFoundError ncdfe) {
+            // good
+        }
+        try {
+            foo = obj instanceof UnresClass;
+            assert(false);
+        } catch (NoClassDefFoundError ncdfe) {
+            // good
+        }
+
+        return foo;
+    }
+
+    public static void run() {
+        System.out.println("UnresTest2...");
+        UnresClass un;
+        UnresStuff stuff = new UnresStuff();
+
+        try {
+            un = new UnresClass();
+            assert(false);
+        } catch (NoClassDefFoundError ncdfe) {
+            // good
+        }
+
+        try {
+            UnresClass[] uar = new UnresClass[3];
+            assert(false);
+        } catch (NoClassDefFoundError ncdfe) {
+            // good
+        }
+
+        checkCasts(stuff);
+        System.out.println("UnresTest2 done");
+    }
+}
diff --git a/test/003-omnibus-opcodes/src2/UnresStuff.java b/test/003-omnibus-opcodes/src2/UnresStuff.java
new file mode 100644 (file)
index 0000000..56f43af
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * Unresolved classes / fields / methods in a resolved class.
+ *
+ * "happy" version.
+ */
+
+public class UnresStuff {
+    public int x;
+}
diff --git a/test/004-annotations/expected.txt b/test/004-annotations/expected.txt
new file mode 100644 (file)
index 0000000..8f19c4c
--- /dev/null
@@ -0,0 +1,96 @@
+TestAnnotations...
+java.lang.String android.test.anno.TestAnnotations.thing1: @android.test.anno.AnnoArrayField(bb=[], cc=[a, b], dd=[0.987654321], ff=[3.1415927], ii=[], jj=[], ss=[], str=[], zz=[])
+java.lang.String android.test.anno.TestAnnotations.thing2: @android.test.anno.AnnoArrayField(bb=[-1, 0, 1], cc=[Q], dd=[0.3, 0.6, 0.9], ff=[1.1, 1.2, 1.3], ii=[1, 2, 3, 4], jj=[-5, 0, 5], ss=[12, 13, 14, 15, 16, 17], str=[hickory, dickory, dock], zz=[true, false, true])
+mapping is class [Landroid.test.anno.IntToString;
+  0='@android.test.anno.IntToString(from=0, to=NORMAL_FOCUS)'
+  1='@android.test.anno.IntToString(from=2, to=WEAK_FOCUS)'
+present(getFocusType, ExportedProperty): true
+present(getFocusType, AnnoSimpleType): false
+
+AnnoSimpleField true, SimplyNoted false
+annotations on TYPE class android.test.anno.SimplyNoted(2):
+  @android.test.anno.AnnoSimpleType()
+    interface android.test.anno.AnnoSimpleType
+  @android.test.anno.AnnoSimpleType2()
+    interface android.test.anno.AnnoSimpleType2
+
+  annotations on CTOR android.test.anno.SimplyNoted():
+    @android.test.anno.AnnoSimpleConstructor()
+      interface android.test.anno.AnnoSimpleConstructor
+    constructor parameter annotations:
+  annotations on CTOR android.test.anno.SimplyNoted(int):
+    @android.test.anno.AnnoSimpleConstructor()
+      interface android.test.anno.AnnoSimpleConstructor
+    constructor parameter annotations:
+      @android.test.anno.AnnoSimpleParameter()
+        interface android.test.anno.AnnoSimpleParameter
+  annotations on METH public int android.test.anno.SimplyNoted.foo():
+    @android.test.anno.AnnoSimpleMethod()
+      interface android.test.anno.AnnoSimpleMethod
+    method parameter annotations:
+  annotations on FIELD public static int android.test.anno.SimplyNoted.mOneFoo:
+    @android.test.anno.AnnoSimpleField()
+      interface android.test.anno.AnnoSimpleField
+  annotations on FIELD public int android.test.anno.SimplyNoted.mFoo:
+    @android.test.anno.AnnoSimpleField()
+      interface android.test.anno.AnnoSimpleField
+
+annotations on TYPE interface android.test.anno.INoted(1):
+  @android.test.anno.AnnoSimpleType2()
+    interface android.test.anno.AnnoSimpleType2
+
+  annotations on METH public abstract int android.test.anno.INoted.bar():
+    @android.test.anno.AnnoSimpleMethod()
+      interface android.test.anno.AnnoSimpleMethod
+    method parameter annotations:
+
+annotations on TYPE class android.test.anno.SubNoted(3):
+  @android.test.anno.AnnoFancyType(name=unknown, num=5)
+    interface android.test.anno.AnnoFancyType
+  @android.test.anno.AnnoSimpleType()
+    interface android.test.anno.AnnoSimpleType
+  @android.test.anno.AnnoSimpleType2()
+    interface android.test.anno.AnnoSimpleType2
+
+  annotations on CTOR public android.test.anno.SubNoted():
+    constructor parameter annotations:
+  annotations on METH public int android.test.anno.SubNoted.bar():
+    method parameter annotations:
+  annotations on FIELD int android.test.anno.SubNoted.mBar:
+
+annotations on TYPE class android.test.anno.FullyNoted(1):
+  @android.test.anno.AnnoFancyType(name=full, num=5)
+    interface android.test.anno.AnnoFancyType
+
+  annotations on CTOR android.test.anno.FullyNoted(int):
+    @android.test.anno.AnnoFancyConstructor(numArgs=1)
+      interface android.test.anno.AnnoFancyConstructor
+    constructor parameter annotations:
+      @android.test.anno.AnnoFancyParameter(factor=0.5)
+        interface android.test.anno.AnnoFancyParameter
+  annotations on METH public int android.test.anno.FullyNoted.bar(int,long) throws java.io.IOException,java.io.EOFException:
+    @android.test.anno.AnnoFancyMethod(biteMe=false, callMe=true, enumerated=FOO, someClass=class android.test.anno.SomeClass)
+      interface android.test.anno.AnnoFancyMethod
+    method parameter annotations:
+      @android.test.anno.AnnoSimpleParameter()
+        interface android.test.anno.AnnoSimpleParameter
+      @android.test.anno.AnnoFancyParameter(factor=3.7879912899761)
+        interface android.test.anno.AnnoFancyParameter
+  annotations on METH public int android.test.anno.FullyNoted.bar1(int,long) throws java.io.IOException:
+    @android.test.anno.AnnoFancyMethod(biteMe=true, callMe=false, enumerated=BAR, someClass=class android.test.anno.SomeClass)
+      interface android.test.anno.AnnoFancyMethod
+    method parameter annotations:
+      @android.test.anno.AnnoSimpleParameter()
+        interface android.test.anno.AnnoSimpleParameter
+      @android.test.anno.AnnoFancyParameter(factor=3.7879912899761)
+        interface android.test.anno.AnnoFancyParameter
+  annotations on METH public int android.test.anno.FullyNoted.notAnnotated():
+    method parameter annotations:
+  annotations on FIELD int android.test.anno.FullyNoted.mBar:
+    @android.test.anno.AnnoFancyField(nombre=fubar)
+      interface android.test.anno.AnnoFancyField
+    aff: @android.test.anno.AnnoFancyField(nombre=fubar) / class $Proxy13
+    --> nombre is 'fubar'
+
+SimplyNoted.get(AnnoSimpleType) = @android.test.anno.AnnoSimpleType()
+SubNoted.get(AnnoSimpleType) = @android.test.anno.AnnoSimpleType()
diff --git a/test/004-annotations/info.txt b/test/004-annotations/info.txt
new file mode 100644 (file)
index 0000000..c8c9280
--- /dev/null
@@ -0,0 +1 @@
+Test a bunch of uses of annotations.
diff --git a/test/004-annotations/src/Main.java b/test/004-annotations/src/Main.java
new file mode 100644 (file)
index 0000000..e44722f
--- /dev/null
@@ -0,0 +1,7 @@
+import android.test.anno.TestAnnotations;
+
+public class Main {
+    static public void main(String[] args) {
+        TestAnnotations.main(args);
+    }
+}
diff --git a/test/004-annotations/src/android/test/anno/AnnoArrayField.java b/test/004-annotations/src/android/test/anno/AnnoArrayField.java
new file mode 100644 (file)
index 0000000..681045c
--- /dev/null
@@ -0,0 +1,19 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Documented
+@Inherited
+@Target({ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AnnoArrayField {
+    boolean[] zz() default {};
+    byte[] bb() default {};
+    char[] cc() default {'a', 'b'};
+    short[] ss() default {};
+    int[] ii() default {};
+    float[] ff() default {3.141592654f};
+    long[] jj() default {};
+    double[] dd() default {0.987654321};
+    String[] str() default {};
+}
diff --git a/test/004-annotations/src/android/test/anno/AnnoFancyConstructor.java b/test/004-annotations/src/android/test/anno/AnnoFancyConstructor.java
new file mode 100644 (file)
index 0000000..19dadec
--- /dev/null
@@ -0,0 +1,10 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.CONSTRUCTOR)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AnnoFancyConstructor {
+    public int numArgs() default 0;
+}
diff --git a/test/004-annotations/src/android/test/anno/AnnoFancyField.java b/test/004-annotations/src/android/test/anno/AnnoFancyField.java
new file mode 100644 (file)
index 0000000..855ba56
--- /dev/null
@@ -0,0 +1,12 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited      // should have no effect
+@Documented
+
+public @interface AnnoFancyField {
+    public String nombre() default "no se";
+}
diff --git a/test/004-annotations/src/android/test/anno/AnnoFancyMethod.java b/test/004-annotations/src/android/test/anno/AnnoFancyMethod.java
new file mode 100644 (file)
index 0000000..3088866
--- /dev/null
@@ -0,0 +1,14 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AnnoFancyMethod {
+    enum AnnoFancyMethodEnum { FOO, BAR };
+    boolean callMe() default false;
+    boolean biteMe();
+    AnnoFancyMethodEnum enumerated() default AnnoFancyMethodEnum.FOO;
+    Class someClass() default SomeClass.class;
+}
diff --git a/test/004-annotations/src/android/test/anno/AnnoFancyParameter.java b/test/004-annotations/src/android/test/anno/AnnoFancyParameter.java
new file mode 100644 (file)
index 0000000..bc2ba7c
--- /dev/null
@@ -0,0 +1,10 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.PARAMETER)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AnnoFancyParameter {
+    double factor();
+}
diff --git a/test/004-annotations/src/android/test/anno/AnnoFancyType.java b/test/004-annotations/src/android/test/anno/AnnoFancyType.java
new file mode 100644 (file)
index 0000000..745f838
--- /dev/null
@@ -0,0 +1,11 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AnnoFancyType {
+    public int num();
+    public String name() default "unknown";
+}
diff --git a/test/004-annotations/src/android/test/anno/AnnoSimpleConstructor.java b/test/004-annotations/src/android/test/anno/AnnoSimpleConstructor.java
new file mode 100644 (file)
index 0000000..d66b9ae
--- /dev/null
@@ -0,0 +1,8 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.CONSTRUCTOR)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AnnoSimpleConstructor {}
diff --git a/test/004-annotations/src/android/test/anno/AnnoSimpleField.java b/test/004-annotations/src/android/test/anno/AnnoSimpleField.java
new file mode 100644 (file)
index 0000000..04193d2
--- /dev/null
@@ -0,0 +1,8 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AnnoSimpleField {}
diff --git a/test/004-annotations/src/android/test/anno/AnnoSimpleLocalVariable.java b/test/004-annotations/src/android/test/anno/AnnoSimpleLocalVariable.java
new file mode 100644 (file)
index 0000000..a839fa2
--- /dev/null
@@ -0,0 +1,8 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.LOCAL_VARIABLE)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AnnoSimpleLocalVariable {}
diff --git a/test/004-annotations/src/android/test/anno/AnnoSimpleMethod.java b/test/004-annotations/src/android/test/anno/AnnoSimpleMethod.java
new file mode 100644 (file)
index 0000000..fcd9c0f
--- /dev/null
@@ -0,0 +1,8 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AnnoSimpleMethod {}
diff --git a/test/004-annotations/src/android/test/anno/AnnoSimplePackage.java b/test/004-annotations/src/android/test/anno/AnnoSimplePackage.java
new file mode 100644 (file)
index 0000000..4aadfe7
--- /dev/null
@@ -0,0 +1,8 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.PACKAGE)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AnnoSimplePackage {}
diff --git a/test/004-annotations/src/android/test/anno/AnnoSimpleParameter.java b/test/004-annotations/src/android/test/anno/AnnoSimpleParameter.java
new file mode 100644 (file)
index 0000000..6e26ca3
--- /dev/null
@@ -0,0 +1,8 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.PARAMETER)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AnnoSimpleParameter {}
diff --git a/test/004-annotations/src/android/test/anno/AnnoSimpleType.java b/test/004-annotations/src/android/test/anno/AnnoSimpleType.java
new file mode 100644 (file)
index 0000000..3bba3db
--- /dev/null
@@ -0,0 +1,9 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface AnnoSimpleType {}
diff --git a/test/004-annotations/src/android/test/anno/AnnoSimpleType2.java b/test/004-annotations/src/android/test/anno/AnnoSimpleType2.java
new file mode 100644 (file)
index 0000000..f74b291
--- /dev/null
@@ -0,0 +1,8 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+public @interface AnnoSimpleType2 {}
diff --git a/test/004-annotations/src/android/test/anno/AnnoSimpleTypeInvis.java b/test/004-annotations/src/android/test/anno/AnnoSimpleTypeInvis.java
new file mode 100644 (file)
index 0000000..541d82e
--- /dev/null
@@ -0,0 +1,8 @@
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.CLASS)
+
+public @interface AnnoSimpleTypeInvis {}
diff --git a/test/004-annotations/src/android/test/anno/ExportedProperty.java b/test/004-annotations/src/android/test/anno/ExportedProperty.java
new file mode 100644 (file)
index 0000000..810d28f
--- /dev/null
@@ -0,0 +1,12 @@
+/* part of test for array problem */
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target({ ElementType.FIELD, ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface ExportedProperty {
+    boolean resolveId() default false;
+    IntToString[] mapping() default { @IntToString(from = -1, to = "-1") };
+}
diff --git a/test/004-annotations/src/android/test/anno/FullyNoted.java b/test/004-annotations/src/android/test/anno/FullyNoted.java
new file mode 100644 (file)
index 0000000..76a7b04
--- /dev/null
@@ -0,0 +1,39 @@
+
+package android.test.anno;
+
+import java.io.IOException;
+import java.io.EOFException;
+
+@AnnoFancyType(num=5, name="full")
+public class FullyNoted {
+    @AnnoFancyField(nombre="fubar")
+    int mBar;
+
+    @AnnoFancyConstructor(numArgs=1)
+    FullyNoted(@AnnoFancyParameter(factor=0.5) int bar)
+    {
+        mBar = bar;
+    }
+
+    @AnnoFancyMethod(callMe=true, biteMe=false)
+    public int bar(
+        @AnnoSimpleParameter int one,
+        @AnnoFancyParameter(factor=3.7879912899761) long two)
+        throws IOException, EOFException {
+
+        return 0;
+    }
+
+    @AnnoFancyMethod(biteMe=true, enumerated=AnnoFancyMethod.AnnoFancyMethodEnum.BAR)
+    public int bar1(
+        @AnnoSimpleParameter int one,
+        @AnnoFancyParameter(factor=3.7879912899761) long two)
+        throws IOException {
+
+        return 0;
+    }
+
+    public int notAnnotated() {
+        return 0;
+    }
+}
diff --git a/test/004-annotations/src/android/test/anno/INoted.java b/test/004-annotations/src/android/test/anno/INoted.java
new file mode 100644 (file)
index 0000000..b2cd007
--- /dev/null
@@ -0,0 +1,7 @@
+package android.test.anno;
+
+@AnnoSimpleType2
+public interface INoted {
+    @AnnoSimpleMethod
+    public int bar();
+}
diff --git a/test/004-annotations/src/android/test/anno/IntToString.java b/test/004-annotations/src/android/test/anno/IntToString.java
new file mode 100644 (file)
index 0000000..e84fcfa
--- /dev/null
@@ -0,0 +1,12 @@
+/* part of test for array problem */
+package android.test.anno;
+
+import java.lang.annotation.*;
+
+@Target({ ElementType.TYPE })
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface IntToString {
+    int from();
+    String to();
+}
diff --git a/test/004-annotations/src/android/test/anno/SimplyNoted.java b/test/004-annotations/src/android/test/anno/SimplyNoted.java
new file mode 100644 (file)
index 0000000..95a3d24
--- /dev/null
@@ -0,0 +1,30 @@
+package android.test.anno;
+
+@AnnoSimpleType
+@AnnoSimpleType2
+@AnnoSimpleTypeInvis
+public class SimplyNoted {
+    @AnnoSimpleField
+    public int mFoo;
+
+    @AnnoSimpleField
+    public static int mOneFoo;
+
+    @AnnoSimpleConstructor
+    SimplyNoted() {
+        mFoo = 0;
+    }
+
+    @AnnoSimpleConstructor
+    SimplyNoted(@AnnoSimpleParameter int xyzzy) {
+        mFoo = xyzzy;
+    }
+
+    @AnnoSimpleMethod
+    public int foo() {
+        @AnnoSimpleLocalVariable
+        int bar = 5;
+
+        return bar;
+    }
+}
diff --git a/test/004-annotations/src/android/test/anno/SomeClass.java b/test/004-annotations/src/android/test/anno/SomeClass.java
new file mode 100644 (file)
index 0000000..c21d68d
--- /dev/null
@@ -0,0 +1,4 @@
+package android.test.anno;
+
+public class SomeClass {
+}
diff --git a/test/004-annotations/src/android/test/anno/SubNoted.java b/test/004-annotations/src/android/test/anno/SubNoted.java
new file mode 100644 (file)
index 0000000..2530346
--- /dev/null
@@ -0,0 +1,12 @@
+package android.test.anno;
+
+@AnnoFancyType(num=5)       // first occurrence of AnnoFancyType
+                            // we inherit @AnnoSimpleType
+@AnnoSimpleType2            // AnnoSimpleType2 here *and* inherited from parent
+public class SubNoted extends SimplyNoted implements INoted {
+    int mBar;
+
+    public int bar() {
+        return 0;
+    }
+}
diff --git a/test/004-annotations/src/android/test/anno/TestAnnotations.java b/test/004-annotations/src/android/test/anno/TestAnnotations.java
new file mode 100644 (file)
index 0000000..4ad32d5
--- /dev/null
@@ -0,0 +1,177 @@
+package android.test.anno;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.TreeMap;
+
+public class TestAnnotations {
+    /**
+     * Print the annotations in sorted order, so as to avoid
+     * any (legitimate) non-determinism with regard to the iteration order.
+     */
+    static private void printAnnotationArray(String prefix, Annotation[] arr) {
+        TreeMap<String, Annotation> sorted =
+            new TreeMap<String, Annotation>();
+
+        for (Annotation a : arr) {
+            sorted.put(a.annotationType().getName(), a);
+        }
+
+        for (Annotation a : sorted.values()) {
+            System.out.println(prefix + "  " + a);
+            System.out.println(prefix + "    " + a.annotationType());
+        }
+    }
+
+    static void printAnnotations(Class clazz) {
+        Annotation[] annos;
+        Annotation[][] parAnnos;
+
+        annos = clazz.getAnnotations();
+        System.out.println("annotations on TYPE " + clazz +
+            "(" + annos.length + "):");
+        printAnnotationArray("", annos);
+        System.out.println();
+
+        for (Constructor c: clazz.getDeclaredConstructors()) {
+            annos = c.getDeclaredAnnotations();
+            System.out.println("  annotations on CTOR " + c + ":");
+            printAnnotationArray("  ", annos);
+
+            System.out.println("    constructor parameter annotations:");
+            for (Annotation[] pannos: c.getParameterAnnotations()) {
+                printAnnotationArray("    ", pannos);
+            }
+        }
+
+        for (Method m: clazz.getDeclaredMethods()) {
+            annos = m.getDeclaredAnnotations();
+            System.out.println("  annotations on METH " + m + ":");
+            printAnnotationArray("  ", annos);
+
+            System.out.println("    method parameter annotations:");
+            for (Annotation[] pannos: m.getParameterAnnotations()) {
+                printAnnotationArray("    ", pannos);
+            }
+        }
+
+        for (Field f: clazz.getDeclaredFields()) {
+            annos = f.getDeclaredAnnotations();
+            System.out.println("  annotations on FIELD " + f + ":");
+            printAnnotationArray("  ", annos);
+
+            AnnoFancyField aff;
+            aff = (AnnoFancyField) f.getAnnotation(AnnoFancyField.class);
+            if (aff != null) {
+                System.out.println("    aff: " + aff + " / " + aff.getClass());
+                System.out.println("    --> nombre is '" + aff.nombre() + "'");
+            }
+        }
+        System.out.println();
+    }
+
+
+    @ExportedProperty(mapping = {
+        @IntToString(from = 0, to = "NORMAL_FOCUS"),
+        @IntToString(from = 2, to = "WEAK_FOCUS")
+    })
+    public int getFocusType() {
+        return 2;
+    }
+
+
+    @AnnoArrayField
+    String thing1;
+
+    @AnnoArrayField(
+            zz = {true,false,true},
+            bb = {-1,0,1},
+            cc = {'Q'},
+            ss = {12,13,14,15,16,17},
+            ii = {1,2,3,4},
+            ff = {1.1f,1.2f,1.3f},
+            jj = {-5,0,5},
+            dd = {0.3,0.6,0.9},
+            str = {"hickory","dickory","dock"}
+            )
+    String thing2;
+
+    public static void testArrays() {
+        TestAnnotations ta = new TestAnnotations();
+        Field field;
+        Annotation[] annotations;
+
+        try {
+            field = TestAnnotations.class.getDeclaredField("thing1");
+            annotations = field.getAnnotations();
+            System.out.println(field + ": " + annotations[0].toString());
+
+            field = TestAnnotations.class.getDeclaredField("thing2");
+            annotations = field.getAnnotations();
+            System.out.println(field + ": " + annotations[0].toString());
+        } catch (NoSuchFieldException nsfe) {
+            throw new RuntimeException(nsfe);
+        }
+    }
+
+    public static void testArrayProblem() {
+        Method meth;
+        ExportedProperty property;
+        final IntToString[] mapping;
+
+        try {
+            meth = TestAnnotations.class.getMethod("getFocusType",
+                    (Class[])null);
+        } catch (NoSuchMethodException nsme) {
+            throw new RuntimeException(nsme);
+        }
+        property = meth.getAnnotation(ExportedProperty.class);
+        mapping = property.mapping();
+
+        System.out.println("mapping is " + mapping.getClass() +
+            "\n  0='" + mapping[0] + "'\n  1='" + mapping[1] + "'");
+
+        /* while we're here, check isAnnotationPresent on Method */
+        System.out.println("present(getFocusType, ExportedProperty): " +
+            meth.isAnnotationPresent(ExportedProperty.class));
+        System.out.println("present(getFocusType, AnnoSimpleType): " +
+            meth.isAnnotationPresent(AnnoSimpleType.class));
+
+        System.out.println("");
+    }
+
+
+
+    public static void main(String[] args) {
+        System.out.println("TestAnnotations...");
+
+        testArrays();
+        testArrayProblem();
+        //System.exit(0);
+
+        System.out.println(
+            "AnnoSimpleField " + AnnoSimpleField.class.isAnnotation() +
+            ", SimplyNoted " + SimplyNoted.class.isAnnotation());
+
+        Class clazz;
+        clazz = SimplyNoted.class;
+        printAnnotations(clazz);
+        clazz = INoted.class;
+        printAnnotations(clazz);
+        clazz = SubNoted.class;
+        printAnnotations(clazz);
+        clazz = FullyNoted.class;
+        printAnnotations(clazz);
+
+        Annotation anno;
+
+        // this is expected to be non-null
+        anno = SimplyNoted.class.getAnnotation(AnnoSimpleType.class);
+        System.out.println("SimplyNoted.get(AnnoSimpleType) = " + anno);
+        // this is non-null if the @Inherited tag is present
+        anno = SubNoted.class.getAnnotation(AnnoSimpleType.class);
+        System.out.println("SubNoted.get(AnnoSimpleType) = " + anno);
+    }
+}
diff --git a/test/004-annotations/src/android/test/anno/package-info.java b/test/004-annotations/src/android/test/anno/package-info.java
new file mode 100644 (file)
index 0000000..74b11f9
--- /dev/null
@@ -0,0 +1,2 @@
+@AnnoSimplePackage
+package android.test.anno;
diff --git a/test/005-args/expected.txt b/test/005-args/expected.txt
new file mode 100644 (file)
index 0000000..094fbbb
--- /dev/null
@@ -0,0 +1,5 @@
+VALUES: 1122334455667788 9887766554433221 1122334455667788
+VALUES: 1234605616436508552 -7455860480511102431 1234605616436508552
+1234605616436508552
+j = 1234605616436508552
+a=123 c=q d=3.343434 j=1234605616436508552 f=0.12345
diff --git a/test/005-args/info.txt b/test/005-args/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/005-args/src/ArgsTest.java b/test/005-args/src/ArgsTest.java
new file mode 100644 (file)
index 0000000..2b874cd
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class ArgsTest{
+    public ArgsTest() {
+
+    }
+
+    private long mLongArray[] = new long[] {
+        0x1122334455667788L, 0x9887766554433221L };
+
+    /**
+     *
+     * @param a
+     * @param c
+     * @param d
+     * @param j
+     * @param f
+     */
+    void argTest(int a, char c, double d, long j, float f) {
+        System.out.println("VALUES: " + Long.toHexString(mLongArray[0]) + " "
+            + Long.toHexString(mLongArray[1]) + " " + Long.toHexString(j));
+        System.out.println("VALUES: " + mLongArray[0] + " "
+            + mLongArray[1] + " " + j);
+
+        System.out.println(j);
+        System.out.println("j = " + j);
+        System.out.println("a=" + a + " c=" + c + " d=" + d
+            + " j=" + j + " f=" + f);
+    }
+}
diff --git a/test/005-args/src/Main.java b/test/005-args/src/Main.java
new file mode 100644 (file)
index 0000000..1240ec5
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Test passing arguments of various sizes
+ */
+public class Main {
+    public static void main (String args[]) {
+        new ArgsTest()
+                .argTest(123, 'q', 3.343434, 0x1122334455667788L, 0.12345f);
+    }
+}
diff --git a/test/006-count10/expected.txt b/test/006-count10/expected.txt
new file mode 100644 (file)
index 0000000..8b1acc1
--- /dev/null
@@ -0,0 +1,10 @@
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
diff --git a/test/006-count10/info.txt b/test/006-count10/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/006-count10/src/Main.java b/test/006-count10/src/Main.java
new file mode 100644 (file)
index 0000000..650d053
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Simple loop-and-print
+ */
+public class Main {
+    public static void main(String args[]) {
+        for (int i = 0; i < 10; i++) {
+            System.out.println(i);
+        }
+    }
+}
diff --git a/test/007-exceptions/expected.txt b/test/007-exceptions/expected.txt
new file mode 100644 (file)
index 0000000..2a31636
--- /dev/null
@@ -0,0 +1,9 @@
+Got an NPE: second throw
+java.lang.NullPointerException: second throw
+       at Main.catchAndRethrow(Main.java:36)
+       at Main.main(Main.java:23)
+       at dalvik.system.NativeStart.main(Native Method)
+Caused by: java.lang.NullPointerException: first throw
+       at Main.throwNullPointerException(Main.java:43)
+       at Main.catchAndRethrow(Main.java:33)
+       ... 2 more
diff --git a/test/007-exceptions/info.txt b/test/007-exceptions/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/007-exceptions/src/Main.java b/test/007-exceptions/src/Main.java
new file mode 100644 (file)
index 0000000..c7da215
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Exceptions across method calls
+ */
+public class Main {
+    public static void main (String args[]) {
+        try {
+            catchAndRethrow();
+        } catch (NullPointerException npe) {
+            System.out.print("Got an NPE: ");
+            System.out.println(npe.getMessage());
+            npe.printStackTrace();
+        }
+    }
+
+    private static void catchAndRethrow() {
+        try {
+            throwNullPointerException();
+        } catch (NullPointerException npe) {
+            NullPointerException npe2;
+            npe2 = new NullPointerException("second throw");
+            npe2.initCause(npe);
+            throw npe2;
+        }
+    }
+
+    private static void throwNullPointerException() {
+        throw new NullPointerException("first throw");
+    }
+}
diff --git a/test/008-instanceof/expected.txt b/test/008-instanceof/expected.txt
new file mode 100644 (file)
index 0000000..77fd0cb
--- /dev/null
@@ -0,0 +1,6 @@
+iface1.mFloaty = 5.0 wahoo
+aa.mFloaty = 5.0 wahoo
+bb.mWhoami = ImplB!
+aaOkay (false) = false
+bbOkay (true) = true
+Caught a ClassCastException (expected)
diff --git a/test/008-instanceof/info.txt b/test/008-instanceof/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/008-instanceof/src/Iface1.java b/test/008-instanceof/src/Iface1.java
new file mode 100644 (file)
index 0000000..ba17d45
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2005 The Android Open Source Project
+
+/**
+ * Test stuff.
+ */
+public interface Iface1 {
+
+    public int iFunc1(int ii);
+
+    public float mFloaty = 5.0f;
+
+    public String mWahoo = new String("wahoo");
+}
diff --git a/test/008-instanceof/src/Iface2.java b/test/008-instanceof/src/Iface2.java
new file mode 100644 (file)
index 0000000..83fe650
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Another interface.
+ */
+public interface Iface2 {
+
+    public int iFunc2(int ii);
+}
diff --git a/test/008-instanceof/src/Iface2Sub1.java b/test/008-instanceof/src/Iface2Sub1.java
new file mode 100644 (file)
index 0000000..db3e905
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Another interface.
+ */
+public interface Iface2Sub1 extends Iface2, Cloneable {
+
+    //public int iFunc2(int ii);
+}
diff --git a/test/008-instanceof/src/ImplA.java b/test/008-instanceof/src/ImplA.java
new file mode 100644 (file)
index 0000000..9007001
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Blah.
+ */
+public class ImplA implements Iface1, Iface2 {
+
+    public int iFunc1(int ii) {
+        return ii+1;
+    }
+    public int iFunc2(int ii) {
+        return ii+2;
+    }
+}
diff --git a/test/008-instanceof/src/ImplB.java b/test/008-instanceof/src/ImplB.java
new file mode 100644 (file)
index 0000000..619fa00
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Blah.
+ */
+public class ImplB implements Iface1, Iface2 {
+
+    public int iFunc1(int ii) {
+        return ii+10;
+    }
+    public int iFunc2(int ii) {
+        return ii+20;
+    }
+
+    public static String mWhoami = new String("ImplB!");
+}
diff --git a/test/008-instanceof/src/ImplBSub.java b/test/008-instanceof/src/ImplBSub.java
new file mode 100644 (file)
index 0000000..f3a7714
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Interface test.
+ */
+public class ImplBSub extends ImplB implements /*Iface2,*/ Iface2Sub1 {
+
+    public int iFunc1(int ii) {
+        return ii+100;
+    }
+    public int iFunc2(int ii) {
+        return ii+200;
+    }
+}
diff --git a/test/008-instanceof/src/Main.java b/test/008-instanceof/src/Main.java
new file mode 100644 (file)
index 0000000..77f3f51
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Test instanceof
+ */
+public class Main {
+    public static void main(String args[]) {
+        Iface1 face1;
+        ImplA aa = new ImplA();
+        ImplBSub bb = new ImplBSub();
+        boolean aaOkay, bbOkay;
+
+        face1 = aa;
+        face1 = bb;
+
+        System.out.println("iface1.mFloaty = " + face1.mFloaty + " " + face1.mWahoo);
+        System.out.println("aa.mFloaty = " + aa.mFloaty + " " + aa.mWahoo);
+        System.out.println("bb.mWhoami = " + bb.mWhoami);
+
+        aaOkay = face1 instanceof ImplA;
+        System.out.print("aaOkay (false) = ");
+        System.out.println(aaOkay);
+        bbOkay = face1 instanceof ImplB;
+        System.out.print("bbOkay (true) = ");
+        System.out.println(bbOkay);
+
+        bb = (ImplBSub) face1;
+        try {
+            aa = (ImplA) face1;
+        }
+        catch (ClassCastException cce) {
+            System.out.println("Caught a ClassCastException (expected)");
+        }
+    }
+}
diff --git a/test/009-instanceof2/expected.txt b/test/009-instanceof2/expected.txt
new file mode 100644 (file)
index 0000000..74ad202
--- /dev/null
@@ -0,0 +1,5 @@
+instanceof Serializable = true
+instanceof Cloneable = true
+instanceof Runnable = false
+aaOkay (false) = false
+bbOkay (true) = true
diff --git a/test/009-instanceof2/info.txt b/test/009-instanceof2/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/009-instanceof2/src/Iface1.java b/test/009-instanceof2/src/Iface1.java
new file mode 100644 (file)
index 0000000..ba17d45
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2005 The Android Open Source Project
+
+/**
+ * Test stuff.
+ */
+public interface Iface1 {
+
+    public int iFunc1(int ii);
+
+    public float mFloaty = 5.0f;
+
+    public String mWahoo = new String("wahoo");
+}
diff --git a/test/009-instanceof2/src/Iface2.java b/test/009-instanceof2/src/Iface2.java
new file mode 100644 (file)
index 0000000..83fe650
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Another interface.
+ */
+public interface Iface2 {
+
+    public int iFunc2(int ii);
+}
diff --git a/test/009-instanceof2/src/Iface2Sub1.java b/test/009-instanceof2/src/Iface2Sub1.java
new file mode 100644 (file)
index 0000000..db3e905
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Another interface.
+ */
+public interface Iface2Sub1 extends Iface2, Cloneable {
+
+    //public int iFunc2(int ii);
+}
diff --git a/test/009-instanceof2/src/ImplA.java b/test/009-instanceof2/src/ImplA.java
new file mode 100644 (file)
index 0000000..9007001
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Blah.
+ */
+public class ImplA implements Iface1, Iface2 {
+
+    public int iFunc1(int ii) {
+        return ii+1;
+    }
+    public int iFunc2(int ii) {
+        return ii+2;
+    }
+}
diff --git a/test/009-instanceof2/src/ImplB.java b/test/009-instanceof2/src/ImplB.java
new file mode 100644 (file)
index 0000000..619fa00
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Blah.
+ */
+public class ImplB implements Iface1, Iface2 {
+
+    public int iFunc1(int ii) {
+        return ii+10;
+    }
+    public int iFunc2(int ii) {
+        return ii+20;
+    }
+
+    public static String mWhoami = new String("ImplB!");
+}
diff --git a/test/009-instanceof2/src/ImplBSub.java b/test/009-instanceof2/src/ImplBSub.java
new file mode 100644 (file)
index 0000000..f3a7714
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Interface test.
+ */
+public class ImplBSub extends ImplB implements /*Iface2,*/ Iface2Sub1 {
+
+    public int iFunc1(int ii) {
+        return ii+100;
+    }
+    public int iFunc2(int ii) {
+        return ii+200;
+    }
+}
diff --git a/test/009-instanceof2/src/Main.java b/test/009-instanceof2/src/Main.java
new file mode 100644 (file)
index 0000000..15a1e50
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * more instanceof cases
+ */
+public class Main {
+    public static void main(String args[]) {
+        Iface1[] faceArray;
+        ImplA[] aaArray = new ImplA[5];
+        ImplBSub[] bbArray = new ImplBSub[5];
+        boolean aaOkay, bbOkay;
+
+        faceArray = aaArray;
+        faceArray = bbArray;
+
+        System.out.print("instanceof Serializable = ");
+        System.out.println((Object)aaArray instanceof java.io.Serializable);
+        System.out.print("instanceof Cloneable = ");
+        System.out.println((Object)aaArray instanceof java.lang.Cloneable);
+        System.out.print("instanceof Runnable = ");
+        System.out.println((Object)aaArray instanceof java.lang.Runnable);
+
+        aaOkay = faceArray instanceof ImplA[];
+        System.out.print("aaOkay (false) = ");
+        System.out.println(aaOkay);
+        bbOkay = faceArray instanceof ImplB[];
+        System.out.print("bbOkay (true) = ");
+        System.out.println(bbOkay);
+    }
+}
diff --git a/test/010-instance/expected.txt b/test/010-instance/expected.txt
new file mode 100644 (file)
index 0000000..219dd06
--- /dev/null
@@ -0,0 +1,30 @@
+instance begin
+x instanceof X (true): true
+x instanceof Y (false): false
+y instanceof X (true): true
+y instanceof Y (true): true
+xar instanceof Object (true): true
+xar instanceof X (false): false
+xar instanceof X[] (true): true
+xar instanceof Y[] (false): false
+xar instanceof Object[] (true): true
+xar instanceof X[][] (false): false
+yar instanceof X[] (true): true
+xararar instanceof Object (true): true
+xararar instanceof Object[] (true): true
+xararar instanceof X (false): false
+xararar instanceof X[] (false): false
+xararar instanceof X[][] (false): false
+xararar instanceof X[][][] (true): true
+xararar instanceof Object[][][] (true): true
+xararar instanceof Serializable (true): true
+xararar instanceof Serializable[] (true): true
+xararar instanceof Serializable[][] (true): true
+xararar instanceof Serializable[][][] (false): false
+yararar instanceof X[][][] (true): true
+iar instanceof Object (true): true
+iar instanceof Object[] (false): false
+iarar instanceof Object (true): true
+iarar instanceof Object[] (true): true
+iarar instanceof Object[][] (false): false
+instanceof end
diff --git a/test/010-instance/info.txt b/test/010-instance/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/010-instance/src/InstanceTest.java b/test/010-instance/src/InstanceTest.java
new file mode 100644 (file)
index 0000000..78384ff
--- /dev/null
@@ -0,0 +1,93 @@
+// Copyright 2006 The Android Open Source Project
+
+import java.io.Serializable;
+
+/**
+ * Test some instanceof stuff.
+ */
+public class InstanceTest {
+    public static void main(String[] args) {
+        System.out.println("instance begin");
+
+        X x = new X();
+        X[] xar = new X[1];
+        X[][] xarar = new X[1][1];
+        X[][][] xararar = new X[1][1][1];
+        Y y = new Y();
+        Y[] yar = new Y[1];
+        Y[][] yarar = new Y[1][1];
+        Y[][][] yararar = new Y[1][1][1];
+        int[] iar = new int[1];
+        int[][] iarar = new int[1][1];
+        Object test;
+
+        test = x;
+        System.out.println("x instanceof X (true): " + (test instanceof X));
+        System.out.println("x instanceof Y (false): " + (test instanceof Y));
+        test = y;
+        System.out.println("y instanceof X (true): " + (test instanceof X));
+        System.out.println("y instanceof Y (true): " + (test instanceof Y));
+
+        test = xar;
+        System.out.println("xar instanceof Object (true): "
+            + (test instanceof Object));
+        System.out.println("xar instanceof X (false): "
+            + (test instanceof X));
+        System.out.println("xar instanceof X[] (true): "
+            + (test instanceof X[]));
+        System.out.println("xar instanceof Y[] (false): "
+            + (test instanceof Y[]));
+        System.out.println("xar instanceof Object[] (true): "
+            + (test instanceof Object[]));
+        System.out.println("xar instanceof X[][] (false): "
+            + (test instanceof X[][]));
+        test = yar;
+        System.out.println("yar instanceof X[] (true): "
+            + (test instanceof X[]));
+
+        test = xararar;
+        System.out.println("xararar instanceof Object (true): "
+            + (test instanceof Object));
+        System.out.println("xararar instanceof Object[] (true): "
+            + (test instanceof Object[]));
+        System.out.println("xararar instanceof X (false): "
+            + (test instanceof X));
+        System.out.println("xararar instanceof X[] (false): "
+            + (test instanceof X[]));
+        System.out.println("xararar instanceof X[][] (false): "
+            + (test instanceof X[][]));
+        System.out.println("xararar instanceof X[][][] (true): "
+            + (test instanceof X[][][]));
+        System.out.println("xararar instanceof Object[][][] (true): "
+            + (test instanceof Object[][][]));
+
+        System.out.println("xararar instanceof Serializable (true): "
+            + (test instanceof Serializable));
+        System.out.println("xararar instanceof Serializable[] (true): "
+            + (test instanceof Serializable[]));
+        System.out.println("xararar instanceof Serializable[][] (true): "
+            + (test instanceof Serializable[][]));
+        System.out.println("xararar instanceof Serializable[][][] (false): "
+            + (test instanceof Serializable[][][]));
+
+        test = yararar;
+        System.out.println("yararar instanceof X[][][] (true): "
+            + (test instanceof X[][][]));
+
+        test = iar;
+        System.out.println("iar instanceof Object (true): "
+            + (test instanceof Object));
+        System.out.println("iar instanceof Object[] (false): "
+            + (test instanceof Object[]));
+
+        test = iarar;
+        System.out.println("iarar instanceof Object (true): "
+            + (test instanceof Object));
+        System.out.println("iarar instanceof Object[] (true): "
+            + (test instanceof Object[]));
+        System.out.println("iarar instanceof Object[][] (false): "
+            + (test instanceof Object[][]));
+
+        System.out.println("instanceof end");
+    }
+}
diff --git a/test/010-instance/src/Main.java b/test/010-instance/src/Main.java
new file mode 100644 (file)
index 0000000..ab0ab5e
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * even more instanceof cases
+ */
+public class Main {
+    public static void main(String args[]) {
+        InstanceTest.main(null);
+    }
+}
diff --git a/test/010-instance/src/X.java b/test/010-instance/src/X.java
new file mode 100644 (file)
index 0000000..d664d48
--- /dev/null
@@ -0,0 +1,8 @@
+class X {
+    public X() {
+    }
+
+    int foo() {
+        return 0;
+    }
+}
diff --git a/test/010-instance/src/Y.java b/test/010-instance/src/Y.java
new file mode 100644 (file)
index 0000000..2b2c371
--- /dev/null
@@ -0,0 +1,8 @@
+class Y extends X {
+    public Y() {
+    }
+
+    int bar() {
+        return 1;
+    }
+}
diff --git a/test/011-array-copy/expected.txt b/test/011-array-copy/expected.txt
new file mode 100644 (file)
index 0000000..724786e
--- /dev/null
@@ -0,0 +1,15 @@
+string -> object
+object -> string
+object -> string (modified)
+caught ArrayStoreException (expected)
+copy: 0,0,0: [0, 1, 2, 3, 4, 5, 6, 7]
+copy: 0,0,8: [0, 1, 2, 3, 4, 5, 6, 7]
+copy: 0,2,4: [0, 1, 0, 1, 2, 3, 6, 7]
+copy: 2,0,4: [2, 3, 4, 5, 4, 5, 6, 7]
+copy: 1,3,4: [0, 1, 2, 1, 2, 3, 4, 7]
+copy: 3,1,4: [0, 3, 4, 5, 6, 5, 6, 7]
+copy: 3,1,5: [0, 3, 4, 5, 6, 7, 6, 7]
+copy: 1,3,5: [0, 1, 2, 1, 2, 3, 4, 5]
+copy: 0,3,5: [0, 1, 2, 0, 1, 2, 3, 4]
+copy: 3,0,5: [3, 4, 5, 6, 7, 5, 6, 7]
+copy: 0,5,1: [0, 1, 2, 3, 4, 0, 6, 7]
diff --git a/test/011-array-copy/info.txt b/test/011-array-copy/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/011-array-copy/src/Iface1.java b/test/011-array-copy/src/Iface1.java
new file mode 100644 (file)
index 0000000..ba17d45
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2005 The Android Open Source Project
+
+/**
+ * Test stuff.
+ */
+public interface Iface1 {
+
+    public int iFunc1(int ii);
+
+    public float mFloaty = 5.0f;
+
+    public String mWahoo = new String("wahoo");
+}
diff --git a/test/011-array-copy/src/Iface2.java b/test/011-array-copy/src/Iface2.java
new file mode 100644 (file)
index 0000000..83fe650
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Another interface.
+ */
+public interface Iface2 {
+
+    public int iFunc2(int ii);
+}
diff --git a/test/011-array-copy/src/ImplA.java b/test/011-array-copy/src/ImplA.java
new file mode 100644 (file)
index 0000000..9007001
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Blah.
+ */
+public class ImplA implements Iface1, Iface2 {
+
+    public int iFunc1(int ii) {
+        return ii+1;
+    }
+    public int iFunc2(int ii) {
+        return ii+2;
+    }
+}
diff --git a/test/011-array-copy/src/Main.java b/test/011-array-copy/src/Main.java
new file mode 100644 (file)
index 0000000..505d8b0
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Arrays;
+
+/**
+ * System.arraycopy cases
+ */
+public class Main {
+    public static void main(String args[]) {
+        testObjectCopy();
+        testOverlappingMoves();
+    }
+
+    public static void testObjectCopy() {
+        String[] stringArray = new String[8];
+        Object[] objectArray = new Object[8];
+
+        for (int i = 0; i < stringArray.length; i++)
+            stringArray[i] = new String(Integer.toString(i));
+
+        System.out.println("string -> object");
+        System.arraycopy(stringArray, 0, objectArray, 0, stringArray.length);
+        System.out.println("object -> string");
+        System.arraycopy(objectArray, 0, stringArray, 0, stringArray.length);
+        System.out.println("object -> string (modified)");
+        objectArray[4] = new ImplA();
+        try {
+            System.arraycopy(objectArray, 0, stringArray, 0,stringArray.length);
+        }
+        catch (ArrayStoreException ase) {
+            System.out.println("caught ArrayStoreException (expected)");
+        }
+    }
+
+    static final int ARRAY_SIZE = 8;
+
+    static void initByteArray(byte[] array) {
+        for (int i = 0; i < ARRAY_SIZE; i++) {
+            array[i] = (byte) i;
+        }
+    }
+    static void initShortArray(short[] array) {
+        for (int i = 0; i < ARRAY_SIZE; i++) {
+            array[i] = (short) i;
+        }
+    }
+    static void initIntArray(int[] array) {
+        for (int i = 0; i < ARRAY_SIZE; i++) {
+            array[i] = (int) i;
+        }
+    }
+    static void initLongArray(long[] array) {
+        for (int i = 0; i < ARRAY_SIZE; i++) {
+            array[i] = (long) i;
+        }
+    }
+
+    /*
+     * Perform an array copy operation on primitive arrays with different
+     * element widths.
+     */
+    static void makeCopies(int srcPos, int dstPos, int length) {
+        byte[] byteArray = new byte[ARRAY_SIZE];
+        short[] shortArray = new short[ARRAY_SIZE];
+        int[] intArray = new int[ARRAY_SIZE];
+        long[] longArray = new long[ARRAY_SIZE];
+
+        initByteArray(byteArray);
+        initShortArray(shortArray);
+        initIntArray(intArray);
+        initLongArray(longArray);
+
+        System.arraycopy(byteArray, srcPos, byteArray, dstPos, length);
+        System.arraycopy(shortArray, srcPos, shortArray, dstPos, length);
+        System.arraycopy(intArray, srcPos, intArray, dstPos, length);
+        System.arraycopy(longArray, srcPos, longArray, dstPos, length);
+
+        for (int i = 0; i < ARRAY_SIZE; i++) {
+            if (intArray[i] != byteArray[i]) {
+                System.out.println("mismatch int vs byte at " + i + " : " +
+                    Arrays.toString(byteArray));
+                break;
+            } else if (intArray[i] != shortArray[i]) {
+                System.out.println("mismatch int vs short at " + i + " : " +
+                    Arrays.toString(shortArray));
+                break;
+            } else if (intArray[i] != longArray[i]) {
+                System.out.println("mismatch int vs long at " + i + " : " +
+                    Arrays.toString(longArray));
+                break;
+            }
+        }
+
+        System.out.println("copy: " + srcPos + "," + dstPos + "," + length +
+            ": " + Arrays.toString(intArray));
+    }
+
+    public static void testOverlappingMoves() {
+        /* do nothing */
+        makeCopies(0, 0, 0);
+
+        /* do more nothing */
+        makeCopies(0, 0, ARRAY_SIZE);
+
+        /* copy forward, even alignment */
+        makeCopies(0, 2, 4);
+
+        /* copy backward, even alignment */
+        makeCopies(2, 0, 4);
+
+        /* copy forward, odd alignment */
+        makeCopies(1, 3, 4);
+
+        /* copy backward, odd alignment */
+        makeCopies(3, 1, 4);
+
+        /* copy backward, odd length */
+        makeCopies(3, 1, 5);
+
+        /* copy forward, odd length */
+        makeCopies(1, 3, 5);
+
+        /* copy forward, mixed alignment */
+        makeCopies(0, 3, 5);
+
+        /* copy backward, mixed alignment */
+        makeCopies(3, 0, 5);
+
+        /* copy forward, mixed alignment, trivial length */
+        makeCopies(0, 5, 1);
+    }
+}
diff --git a/test/012-math/expected.txt b/test/012-math/expected.txt
new file mode 100644 (file)
index 0000000..af9708e
--- /dev/null
@@ -0,0 +1,32 @@
+res:10
+res:-4
+res:2
+res:-2
+res:21
+res:0
+res:3
+res:4
+res:384
+res:0
+res:0
+a:10
+a:3
+a:2
+a:-3
+a:-21
+a:-3
+a:-3
+a:-6
+a:-768
+a:-6
+a:33554431
+fres:10.0
+fres:-4.0
+fres:21.0
+fres:0.42857142857142855
+fres:3.0
+f:10.0
+f:3.0
+f:21.0
+f:3.0
+f:3.0
diff --git a/test/012-math/info.txt b/test/012-math/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/012-math/src/Main.java b/test/012-math/src/Main.java
new file mode 100644 (file)
index 0000000..87ea40b
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * test simple math opers
+ */
+public class Main {
+    public static void main(String args[]) {
+        int pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7;
+        int pad8, pad9, pad10, pad11, pad12, pad13, pad14, pad15;
+        int a, b, res;
+        //long a, b, res;
+
+        a = 3;
+        b = 7;
+
+        res = a + b;
+        System.out.println("res:" +res);
+        res = a - b;
+        System.out.println("res:" +res);
+        res = 5 - a;
+        System.out.println("res:" +res);
+        res = a - 5;
+        System.out.println("res:" +res);
+        res = a * b;
+        System.out.println("res:" +res);
+        res = a / b;
+        System.out.println("res:" +res);
+        res = a % b;
+        System.out.println("res:" +res);
+        res = a ^ b;
+        System.out.println("res:" +res);
+        res = a << b;
+        System.out.println("res:" +res);
+        res = a >> b;
+        System.out.println("res:" +res);
+        res = a >>> b;
+        System.out.println("res:" +res);
+
+        a += b;
+        System.out.println("a:" +a);
+        a -= b;
+        System.out.println("a:" +a);
+        a = 5 - a;
+        System.out.println("a:" +a);
+        a -= 5;
+        System.out.println("a:" +a);
+        a *= b;
+        System.out.println("a:" +a);
+        a /= b;
+        System.out.println("a:" +a);
+        a %= b;
+        System.out.println("a:" +a);
+        a ^= b;
+        System.out.println("a:" +a);
+        a <<= b;
+        System.out.println("a:" +a);
+        a >>= b;
+        System.out.println("a:" +a);
+        a >>>= b;
+        System.out.println("a:" +a);
+
+        double f, g, fres;
+
+        f = 3.0f;
+        g = 7.0f;
+
+        fres = f + g;
+        System.out.println("fres:" +fres);
+        fres = f - g;
+        System.out.println("fres:" +fres);
+        fres = f * g;
+        System.out.println("fres:" +fres);
+        fres = f / g;
+        System.out.println("fres:" +fres);
+        fres = f % g;
+        System.out.println("fres:" +fres);
+        f += g;
+        System.out.println("f:" +f);
+        f -= g;
+        System.out.println("f:" +f);
+        f *= g;
+        System.out.println("f:" +f);
+        f /= g;
+        System.out.println("f:" +f);
+        f %= g;
+        System.out.println("f:" +f);
+    }
+}
diff --git a/test/013-math2/expected.txt b/test/013-math2/expected.txt
new file mode 100644 (file)
index 0000000..d36c468
--- /dev/null
@@ -0,0 +1 @@
+a:32003
diff --git a/test/013-math2/info.txt b/test/013-math2/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/013-math2/src/Main.java b/test/013-math2/src/Main.java
new file mode 100644 (file)
index 0000000..819571d
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * test add by a 16-bit constant
+ */
+public class Main {
+    public static void main(String args[]) {
+        int a, b, res;
+
+        a = 3;
+        b = 7;
+
+        // a 16-bit constant
+        a += 32000;
+        System.out.println("a:" +a);
+    }
+}
diff --git a/test/014-math3/expected.txt b/test/014-math3/expected.txt
new file mode 100644 (file)
index 0000000..bda3dc7
--- /dev/null
@@ -0,0 +1 @@
+testMath3 success
diff --git a/test/014-math3/info.txt b/test/014-math3/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/014-math3/src/Main.java b/test/014-math3/src/Main.java
new file mode 100644 (file)
index 0000000..f55b17a
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Test math exceptions
+ */
+public class Main {
+    public static void main(String args[]) {
+        int expectedThrows = 2;
+        int i;
+        long j;
+        float f = 0.0f;
+        double d = 0.0;
+
+        try { i = 10 / 0; }
+        catch (ArithmeticException ae) {
+            expectedThrows--;
+        }
+
+        try { j = 10L / 0L; }
+        catch (ArithmeticException ae) {
+            expectedThrows--;
+        }
+
+        /*
+         * Floating point divide by zero doesn't throw an exception -- the
+         * result is just NaN.
+         */
+        try { f = 10.0f / f; }
+        catch (ArithmeticException ae) {
+            expectedThrows--;
+        }
+
+        try { d = 10.0 / d; }
+        catch (ArithmeticException ae) {
+            expectedThrows--;
+        }
+
+        if (expectedThrows != 0)
+            System.out.println("HEY: expected throws is " + expectedThrows);
+        else
+            System.out.println("testMath3 success");
+    }
+}
diff --git a/test/015-switch/expected.txt b/test/015-switch/expected.txt
new file mode 100644 (file)
index 0000000..ca3b518
--- /dev/null
@@ -0,0 +1,10 @@
+CORRECT (one)
+CORRECT (not found)
+CORRECT (large)
+CORRECT (large2)
+CORRECT (large3)
+CORRECT (not found)
+CORRECT (not found)
+CORRECT (default only)
+CORRECT big sparse / first
+CORRECT big sparse / last
diff --git a/test/015-switch/info.txt b/test/015-switch/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/015-switch/src/Main.java b/test/015-switch/src/Main.java
new file mode 100644 (file)
index 0000000..7198e2b
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Test switch() blocks
+ */
+public class Main {
+    public static void main(String args[]) {
+        int a = 1;
+
+        switch (a) {
+            case -1: System.out.print("neg one\n"); break;
+            case 0: System.out.print("zero\n"); break;
+            case 1: System.out.print("CORRECT (one)\n"); break;
+            case 2: System.out.print("two\n"); break;
+            case 3: System.out.print("three\n"); break;
+            case 4: System.out.print("four\n"); break;
+            default: System.out.print("???\n"); break;
+        }
+        switch (a) {
+            case 3: System.out.print("three\n"); break;
+            case 4: System.out.print("four\n"); break;
+            default: System.out.print("CORRECT (not found)\n"); break;
+        }
+
+        a = 0x12345678;
+
+        switch (a) {
+            case 0x12345678: System.out.print("CORRECT (large)\n"); break;
+            case 0x12345679: System.out.print("large+1\n"); break;
+            default: System.out.print("nuts\n"); break;
+        }
+        switch (a) {
+            case 0x12345678: System.out.print("CORRECT (large2)\n"); break;
+            case 0x12345700: System.out.print("large+many\n"); break;
+            default: System.out.print("nuts\n"); break;
+        }
+        switch (a) {
+            case 57: System.out.print("fifty-seven!\n"); break;
+            case -6: System.out.print("neg six!\n"); break;
+            case 0x12345678: System.out.print("CORRECT (large3)\n"); break;
+            case 22: System.out.print("twenty-two!\n"); break;
+            case 3: System.out.print("three!\n"); break;
+            default: System.out.print("huh?\n"); break;
+        }
+        switch (a) {
+            case -6: System.out.print("neg six!\n"); break;
+            case 3: System.out.print("three!\n"); break;
+            default: System.out.print("CORRECT (not found)\n"); break;
+        }
+
+        a = -5;
+        switch (a) {
+            case 12: System.out.print("twelve\n"); break;
+            case -5: System.out.print("CORRECT (not found)\n"); break;
+            case 0: System.out.print("zero\n"); break;
+            default: System.out.print("wah?\n"); break;
+        }
+
+        switch (a) {
+            default: System.out.print("CORRECT (default only)\n"); break;
+        }
+
+        a = -10;
+        switch (a) {
+            case -10: System.out.print("CORRECT big sparse / first\n"); break;
+            case -5: System.out.print("neg five\n"); break;
+            case 0: System.out.print("zero\n"); break;
+            case 5: System.out.print("five\n"); break;
+            case 10: System.out.print("ten\n"); break;
+            case 15: System.out.print("fifteen\n"); break;
+            case 20: System.out.print("twenty\n"); break;
+            case 50: System.out.print("fifty\n"); break;
+            case 100: System.out.print("hundred\n"); break;
+            default: System.out.print("blah!\n"); break;
+        }
+
+        a = 100;
+        switch (a) {
+            case -10: System.out.print("neg ten\n"); break;
+            case -5: System.out.print("neg five\n"); break;
+            case 0: System.out.print("zero\n"); break;
+            case 5: System.out.print("five\n"); break;
+            case 10: System.out.print("ten\n"); break;
+            case 15: System.out.print("fifteen\n"); break;
+            case 20: System.out.print("twenty\n"); break;
+            case 50: System.out.print("fifty\n"); break;
+            case 100: System.out.print("CORRECT big sparse / last\n"); break;
+            default: System.out.print("blah!\n"); break;
+        }
+    }
+}
diff --git a/test/016-intern/expected.txt b/test/016-intern/expected.txt
new file mode 100644 (file)
index 0000000..7d91963
--- /dev/null
@@ -0,0 +1 @@
+good! foobar
diff --git a/test/016-intern/info.txt b/test/016-intern/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/016-intern/src/Main.java b/test/016-intern/src/Main.java
new file mode 100644 (file)
index 0000000..4306863
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Interned strings
+ */
+public class Main {
+    public static void main(String args[]) {
+        String a, b;
+        String foo = "foo";
+        String bar = "bar";
+
+        a = foo.concat(bar).intern();
+        b = foo.concat(bar).intern();
+        if (a == b && foo != bar) {
+            System.out.println("good! " + a);
+        } else {
+            System.out.println("bad!");
+        }
+    }
+}
diff --git a/test/017-float/expected.txt b/test/017-float/expected.txt
new file mode 100644 (file)
index 0000000..2062f9e
--- /dev/null
@@ -0,0 +1,3 @@
+base values: d=3.1415926535 f=3.1415927
+base values: d=3.1415926535 f=3.1415927
+base values: f=3.1415927 d=3.1415926535
diff --git a/test/017-float/info.txt b/test/017-float/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/017-float/src/Main.java b/test/017-float/src/Main.java
new file mode 100644 (file)
index 0000000..a5dbe1e
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * I dont know what this test does.
+ */
+public class Main {
+    public static void main(String args[]) {
+        float f = 3.1415926535f;
+        double d = 3.1415926535;
+        //float fd = (float) d;
+        //Float off = new Float(f);
+        //Float ofd = new Float(d);
+        System.out.println("base values: d=" + d + " f=" + f);
+        System.out.println("base values: d=" + d + " f=" + f);
+        System.out.println("base values: f=" + f + " d=" + d);
+        //System.out.println("object values: off="
+        //    + off.floatValue() + " ofd=" + ofd.floatValue());
+    }
+}
diff --git a/test/018-stack-overflow/expected.txt b/test/018-stack-overflow/expected.txt
new file mode 100644 (file)
index 0000000..7797816
--- /dev/null
@@ -0,0 +1,2 @@
+caught SOE
+SOE test done
diff --git a/test/018-stack-overflow/info.txt b/test/018-stack-overflow/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/018-stack-overflow/src/Main.java b/test/018-stack-overflow/src/Main.java
new file mode 100644 (file)
index 0000000..f79c269
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * generate a stack overflow condition and catch it
+ */
+public class Main {
+    public static void main(String args[]) {
+        try {
+            stackOverflowTestSub(0.0, 0.0, 0.0);
+        }
+        catch (StackOverflowError soe) {
+            System.out.println("caught SOE");
+        }
+        System.out.println("SOE test done");
+    }
+
+    private static void stackOverflowTestSub(double pad1, double pad2,
+            double pad3) {
+        stackOverflowTestSub(pad1, pad2, pad3);
+    }
+}
diff --git a/test/019-wrong-array-type/expected.txt b/test/019-wrong-array-type/expected.txt
new file mode 100644 (file)
index 0000000..c0ed716
--- /dev/null
@@ -0,0 +1 @@
+Got correct array store exception
diff --git a/test/019-wrong-array-type/info.txt b/test/019-wrong-array-type/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/019-wrong-array-type/src/Main.java b/test/019-wrong-array-type/src/Main.java
new file mode 100644 (file)
index 0000000..c424ae9
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Stuff the wrong type object into an array.
+ */
+public class Main {
+    public static void main(String args[]) {
+        String[] strArray = new String[1];
+
+        Object[] objArray = strArray;
+
+        try {
+            objArray[0] = new Integer(1);
+            System.out.println("Array store succeeded?!");
+        } catch (ArrayStoreException ase) {
+            System.out.println("Got correct array store exception");
+        }
+    }
+}
diff --git a/test/020-string/expected.txt b/test/020-string/expected.txt
new file mode 100644 (file)
index 0000000..081fea3
--- /dev/null
@@ -0,0 +1,7 @@
+testStr is 'This is a very nice string'
+This is a very nice string
+Compare result is 32
+Compare unicode: -65302
+Got expected exception
+subStr is 'uick brown fox jumps over the lazy '
+Indexes are: 0:-1:0:43:33:-1:18:13:13:-1:18:18:-1:13:-1:-1:-1
diff --git a/test/020-string/info.txt b/test/020-string/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/020-string/src/Main.java b/test/020-string/src/Main.java
new file mode 100644 (file)
index 0000000..bb8ce1f
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Simple string test.
+ */
+public class Main {
+    public static void main(String args[]) {
+        basicTest();
+        indexTest();
+    }
+
+    public static void basicTest() {
+        String baseStr = "*** This is a very nice string!!!";
+        String testStr;
+        int i;
+
+        testStr = baseStr.substring(4, baseStr.length() - 3);
+        System.out.println("testStr is '" + testStr + "'");
+
+        /* sloppy for loop */
+        for (i = 0; i < testStr.length(); i++)
+            System.out.print(testStr.charAt(i));
+        System.out.print("\n");
+
+        String testStr2 = "This is a very nice strinG";
+        if (testStr.length() != testStr2.length())
+            System.out.println("WARNING: stringTest length mismatch");
+
+        System.out.println("Compare result is " + testStr.compareTo(testStr2));
+
+        // expected: -65302
+        String s1 = "\u0c6d\u0cb6\u0d00\u0000\u0080\u0080\u0080\u0000\u0002\u0002\u0002\u0000\u00e9\u00e9\u00e9";
+        String s2 = "\u0c6d\u0cb6\u0d00\u0000\u0080\u0080\u0080\u0000\u0002\u0002\u0002\u0000\uffff\uffff\uffff\u00e9\u00e9\u00e9";
+        System.out.println("Compare unicode: " + s1.compareTo(s2));
+
+        try {
+            testStr.charAt(500);
+            System.out.println("GLITCH: expected exception");
+        } catch (StringIndexOutOfBoundsException sioobe) {
+            System.out.println("Got expected exception");
+        }
+    }
+
+    public static void indexTest() {
+        String baseStr = "The quick brown fox jumps over the lazy dog!";
+        String subStr;
+
+        subStr = baseStr.substring(5, baseStr.length() - 4);
+        System.out.println("subStr is '" + subStr + "'");
+
+        System.out.println("Indexes are: " +
+            baseStr.indexOf('T') + ":" +
+            subStr.indexOf('T') + ":" +
+            subStr.indexOf('u') + ":" +
+            baseStr.indexOf('!') + ":" +
+            subStr.indexOf('y') + ":" +
+            subStr.indexOf('d') + ":" +
+            baseStr.indexOf('x') + ":" +
+            subStr.indexOf('x', 0) + ":" +
+            subStr.indexOf('x', -1) + ":" +
+            subStr.indexOf('x', 200) + ":" +
+            baseStr.indexOf('x', 17) + ":" +
+            baseStr.indexOf('x', 18) + ":" +
+            baseStr.indexOf('x', 19) + ":" +
+            subStr.indexOf('x', 13) + ":" +
+            subStr.indexOf('x', 14) + ":" +
+            subStr.indexOf('&') + ":" +
+            baseStr.indexOf(0x12341234));
+    }
+}
diff --git a/test/021-string2/expected.txt b/test/021-string2/expected.txt
new file mode 100644 (file)
index 0000000..bd7f049
--- /dev/null
@@ -0,0 +1 @@
+Got expected npe
diff --git a/test/021-string2/info.txt b/test/021-string2/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/021-string2/src/Main.java b/test/021-string2/src/Main.java
new file mode 100644 (file)
index 0000000..87e4baf
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import junit.framework.Assert;
+
+/**
+ * more string tests
+ */
+public class Main {
+    public static void main(String args[]) {
+        String test = "0123456789";
+        String test1 = new String("0123456789");    // different object
+        String test2 = new String("0123456780");    // different value
+        String offset = new String("xxx0123456789yyy");
+        String sub = offset.substring(3, 13);
+        Object blah = new Object();
+
+        Assert.assertTrue(test.equals(test));
+        Assert.assertTrue(test.equals(test1));
+        Assert.assertFalse(test.equals(test2));
+
+        Assert.assertEquals(test.compareTo(test1), 0);
+        Assert.assertTrue(test1.compareTo(test2) > 0);
+        Assert.assertTrue(test2.compareTo(test1) < 0);
+
+        /* compare string with a nonzero offset, in left/right side */
+        Assert.assertEquals(test.compareTo(sub), 0);
+        Assert.assertEquals(sub.compareTo(test), 0);
+        Assert.assertTrue(test.equals(sub));
+        Assert.assertTrue(sub.equals(test));
+        /* same base, one is a substring */
+        Assert.assertFalse(offset.equals(sub));
+        Assert.assertFalse(sub.equals(offset));
+        /* wrong class */
+        Assert.assertFalse(test.equals(blah));
+
+        /* null ptr - throw */
+        try {
+            test.compareTo(null);
+            Assert.fail("didn't get expected npe");
+        } catch (NullPointerException npe) {
+            System.out.println("Got expected npe");
+        }
+        /* null ptr - ok */
+        Assert.assertFalse(test.equals(null));
+
+        test = test.substring(1);
+        Assert.assertTrue(test.equals("123456789"));
+        Assert.assertFalse(test.equals(test1));
+
+        test = test.substring(1);
+        Assert.assertTrue(test.equals("23456789"));
+
+        test = test.substring(1);
+        Assert.assertTrue(test.equals("3456789"));
+
+        test = test.substring(1);
+        Assert.assertTrue(test.equals("456789"));
+
+        test = test.substring(3,5);
+        Assert.assertTrue(test.equals("78"));
+
+        test = "this/is/a/path";
+        String[] strings = test.split("/");
+        Assert.assertEquals(4, strings.length);
+
+        Assert.assertEquals("this is a path", test.replaceAll("/", " "));
+        Assert.assertEquals("this is a path", test.replace("/", " "));
+    }
+}
diff --git a/test/021-string2/src/junit/framework/Assert.java b/test/021-string2/src/junit/framework/Assert.java
new file mode 100644 (file)
index 0000000..364e646
--- /dev/null
@@ -0,0 +1,291 @@
+package junit.framework;
+
+/**
+ * A set of assert methods.  Messages are only displayed when an assert fails.
+ */
+
+public class Assert {
+    /**
+     * Protect constructor since it is a static only class
+     */
+    protected Assert() {
+    }
+
+    /**
+     * Asserts that a condition is true. If it isn't it throws
+     * an AssertionFailedError with the given message.
+     */
+    static public void assertTrue(String message, boolean condition) {
+        if (!condition)
+            fail(message);
+    }
+    /**
+     * Asserts that a condition is true. If it isn't it throws
+     * an AssertionFailedError.
+     */
+    static public void assertTrue(boolean condition) {
+        assertTrue(null, condition);
+    }
+    /**
+     * Asserts that a condition is false. If it isn't it throws
+     * an AssertionFailedError with the given message.
+     */
+    static public void assertFalse(String message, boolean condition) {
+        assertTrue(message, !condition);
+    }
+    /**
+     * Asserts that a condition is false. If it isn't it throws
+     * an AssertionFailedError.
+     */
+    static public void assertFalse(boolean condition) {
+        assertFalse(null, condition);
+    }
+    /**
+     * Fails a test with the given message.
+     */
+    static public void fail(String message) {
+        throw new AssertionFailedError(message);
+    }
+    /**
+     * Fails a test with no message.
+     */
+    static public void fail() {
+        fail(null);
+    }
+    /**
+     * Asserts that two objects are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertEquals(String message, Object expected, Object actual) {
+        if (expected == null && actual == null)
+            return;
+        if (expected != null && expected.equals(actual))
+            return;
+        failNotEquals(message, expected, actual);
+    }
+    /**
+     * Asserts that two objects are equal. If they are not
+     * an AssertionFailedError is thrown.
+     */
+    static public void assertEquals(Object expected, Object actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two Strings are equal.
+     */
+    static public void assertEquals(String message, String expected, String actual) {
+        if (expected == null && actual == null)
+            return;
+        if (expected != null && expected.equals(actual))
+            return;
+        throw new ComparisonFailure(message, expected, actual);
+    }
+    /**
+     * Asserts that two Strings are equal.
+     */
+    static public void assertEquals(String expected, String actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two doubles are equal concerning a delta.  If they are not
+     * an AssertionFailedError is thrown with the given message.  If the expected
+     * value is infinity then the delta value is ignored.
+     */
+    static public void assertEquals(String message, double expected, double actual, double delta) {
+        // handle infinity specially since subtracting to infinite values gives NaN and the
+        // the following test fails
+        if (Double.isInfinite(expected)) {
+            if (!(expected == actual))
+                failNotEquals(message, new Double(expected), new Double(actual));
+        } else if (!(Math.abs(expected-actual) <= delta)) // Because comparison with NaN always returns false
+            failNotEquals(message, new Double(expected), new Double(actual));
+    }
+    /**
+     * Asserts that two doubles are equal concerning a delta. If the expected
+     * value is infinity then the delta value is ignored.
+     */
+    static public void assertEquals(double expected, double actual, double delta) {
+        assertEquals(null, expected, actual, delta);
+    }
+    /**
+     * Asserts that two floats are equal concerning a delta. If they are not
+     * an AssertionFailedError is thrown with the given message.  If the expected
+     * value is infinity then the delta value is ignored.
+     */
+    static public void assertEquals(String message, float expected, float actual, float delta) {
+         // handle infinity specially since subtracting to infinite values gives NaN and the
+        // the following test fails
+        if (Float.isInfinite(expected)) {
+            if (!(expected == actual))
+                failNotEquals(message, new Float(expected), new Float(actual));
+        } else if (!(Math.abs(expected-actual) <= delta))
+              failNotEquals(message, new Float(expected), new Float(actual));
+    }
+    /**
+     * Asserts that two floats are equal concerning a delta. If the expected
+     * value is infinity then the delta value is ignored.
+     */
+    static public void assertEquals(float expected, float actual, float delta) {
+        assertEquals(null, expected, actual, delta);
+    }
+    /**
+     * Asserts that two longs are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertEquals(String message, long expected, long actual) {
+        assertEquals(message, new Long(expected), new Long(actual));
+    }
+    /**
+     * Asserts that two longs are equal.
+     */
+    static public void assertEquals(long expected, long actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two booleans are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertEquals(String message, boolean expected, boolean actual) {
+            assertEquals(message, new Boolean(expected), new Boolean(actual));
+      }
+    /**
+     * Asserts that two booleans are equal.
+      */
+    static public void assertEquals(boolean expected, boolean actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two bytes are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+      static public void assertEquals(String message, byte expected, byte actual) {
+        assertEquals(message, new Byte(expected), new Byte(actual));
+    }
+    /**
+        * Asserts that two bytes are equal.
+     */
+    static public void assertEquals(byte expected, byte actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two chars are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+      static public void assertEquals(String message, char expected, char actual) {
+            assertEquals(message, new Character(expected), new Character(actual));
+      }
+    /**
+     * Asserts that two chars are equal.
+     */
+      static public void assertEquals(char expected, char actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two shorts are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertEquals(String message, short expected, short actual) {
+            assertEquals(message, new Short(expected), new Short(actual));
+    }
+      /**
+     * Asserts that two shorts are equal.
+     */
+    static public void assertEquals(short expected, short actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two ints are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+      static public void assertEquals(String message, int expected, int actual) {
+        assertEquals(message, new Integer(expected), new Integer(actual));
+      }
+      /**
+        * Asserts that two ints are equal.
+     */
+      static public void assertEquals(int expected, int actual) {
+          assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that an object isn't null.
+     */
+    static public void assertNotNull(Object object) {
+        assertNotNull(null, object);
+    }
+    /**
+     * Asserts that an object isn't null. If it is
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertNotNull(String message, Object object) {
+        assertTrue(message, object != null);
+    }
+    /**
+     * Asserts that an object is null.
+     */
+    static public void assertNull(Object object) {
+        assertNull(null, object);
+    }
+    /**
+     * Asserts that an object is null.  If it is not
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertNull(String message, Object object) {
+        assertTrue(message, object == null);
+    }
+    /**
+     * Asserts that two objects refer to the same object. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertSame(String message, Object expected, Object actual) {
+        if (expected == actual)
+            return;
+        failNotSame(message, expected, actual);
+    }
+    /**
+     * Asserts that two objects refer to the same object. If they are not
+     * the same an AssertionFailedError is thrown.
+     */
+    static public void assertSame(Object expected, Object actual) {
+        assertSame(null, expected, actual);
+    }
+     /**
+      * Asserts that two objects refer to the same object. If they are not
+      * an AssertionFailedError is thrown with the given message.
+      */
+    static public void assertNotSame(String message, Object expected, Object actual) {
+        if (expected == actual)
+            failSame(message);
+    }
+    /**
+     * Asserts that two objects refer to the same object. If they are not
+     * the same an AssertionFailedError is thrown.
+     */
+    static public void assertNotSame(Object expected, Object actual) {
+        assertNotSame(null, expected, actual);
+    }
+
+    static private void failSame(String message) {
+        String formatted= "";
+         if (message != null)
+             formatted= message+" ";
+         fail(formatted+"expected not same");
+    }
+
+    static private void failNotSame(String message, Object expected, Object actual) {
+        String formatted= "";
+        if (message != null)
+            formatted= message+" ";
+        fail(formatted+"expected same:<"+expected+"> was not:<"+actual+">");
+    }
+
+    static private void failNotEquals(String message, Object expected, Object actual) {
+        fail(format(message, expected, actual));
+    }
+
+    static String format(String message, Object expected, Object actual) {
+        String formatted= "";
+        if (message != null)
+            formatted= message+" ";
+        return formatted+"expected:<"+expected+"> but was:<"+actual+">";
+    }
+}
diff --git a/test/021-string2/src/junit/framework/AssertionFailedError.java b/test/021-string2/src/junit/framework/AssertionFailedError.java
new file mode 100644 (file)
index 0000000..e9cb3a3
--- /dev/null
@@ -0,0 +1,13 @@
+package junit.framework;
+
+/**
+ * Thrown when an assertion failed.
+ */
+public class AssertionFailedError extends Error {
+
+    public AssertionFailedError () {
+    }
+    public AssertionFailedError (String message) {
+        super (message);
+    }
+}
diff --git a/test/021-string2/src/junit/framework/ComparisonFailure.java b/test/021-string2/src/junit/framework/ComparisonFailure.java
new file mode 100644 (file)
index 0000000..0cb2cee
--- /dev/null
@@ -0,0 +1,68 @@
+package junit.framework;
+
+/**
+ * Thrown when an assert equals for Strings failed.
+ *
+ * Inspired by a patch from Alex Chaffee mailto:alex@purpletech.com
+ */
+public class ComparisonFailure extends AssertionFailedError {
+    private String fExpected;
+    private String fActual;
+
+    /**
+     * Constructs a comparison failure.
+     * @param message the identifying message or null
+     * @param expected the expected string value
+     * @param actual the actual string value
+     */
+    public ComparisonFailure (String message, String expected, String actual) {
+        super (message);
+        fExpected= expected;
+        fActual= actual;
+    }
+
+    /**
+     * Returns "..." in place of common prefix and "..." in
+     * place of common suffix between expected and actual.
+     *
+     * @see java.lang.Throwable#getMessage()
+     */
+    public String getMessage() {
+        if (fExpected == null || fActual == null)
+            return Assert.format(super.getMessage(), fExpected, fActual);
+
+        int end= Math.min(fExpected.length(), fActual.length());
+
+        int i= 0;
+        for(; i < end; i++) {
+            if (fExpected.charAt(i) != fActual.charAt(i))
+                break;
+        }
+        int j= fExpected.length()-1;
+        int k= fActual.length()-1;
+        for (; k >= i && j >= i; k--,j--) {
+            if (fExpected.charAt(j) != fActual.charAt(k))
+                break;
+        }
+        String actual, expected;
+
+        // equal strings
+        if (j < i && k < i) {
+            expected= fExpected;
+            actual= fActual;
+        } else {
+            expected= fExpected.substring(i, j+1);
+            actual= fActual.substring(i, k+1);
+            if (i <= end && i > 0) {
+                expected= "..."+expected;
+                actual= "..."+actual;
+            }
+
+            if (j < fExpected.length()-1)
+                expected= expected+"...";
+            if (k < fActual.length()-1)
+                actual= actual+"...";
+        }
+        return Assert.format(super.getMessage(), expected, actual);
+    }
+}
diff --git a/test/022-interface/expected.txt b/test/022-interface/expected.txt
new file mode 100644 (file)
index 0000000..1212663
--- /dev/null
@@ -0,0 +1,2 @@
+ImplBSub intf: 205
+ImplA: 7
diff --git a/test/022-interface/info.txt b/test/022-interface/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/022-interface/src/Iface1.java b/test/022-interface/src/Iface1.java
new file mode 100644 (file)
index 0000000..ba17d45
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2005 The Android Open Source Project
+
+/**
+ * Test stuff.
+ */
+public interface Iface1 {
+
+    public int iFunc1(int ii);
+
+    public float mFloaty = 5.0f;
+
+    public String mWahoo = new String("wahoo");
+}
diff --git a/test/022-interface/src/Iface2.java b/test/022-interface/src/Iface2.java
new file mode 100644 (file)
index 0000000..83fe650
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Another interface.
+ */
+public interface Iface2 {
+
+    public int iFunc2(int ii);
+}
diff --git a/test/022-interface/src/Iface2Sub1.java b/test/022-interface/src/Iface2Sub1.java
new file mode 100644 (file)
index 0000000..db3e905
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Another interface.
+ */
+public interface Iface2Sub1 extends Iface2, Cloneable {
+
+    //public int iFunc2(int ii);
+}
diff --git a/test/022-interface/src/ImplA.java b/test/022-interface/src/ImplA.java
new file mode 100644 (file)
index 0000000..9007001
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Blah.
+ */
+public class ImplA implements Iface1, Iface2 {
+
+    public int iFunc1(int ii) {
+        return ii+1;
+    }
+    public int iFunc2(int ii) {
+        return ii+2;
+    }
+}
diff --git a/test/022-interface/src/ImplB.java b/test/022-interface/src/ImplB.java
new file mode 100644 (file)
index 0000000..619fa00
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Blah.
+ */
+public class ImplB implements Iface1, Iface2 {
+
+    public int iFunc1(int ii) {
+        return ii+10;
+    }
+    public int iFunc2(int ii) {
+        return ii+20;
+    }
+
+    public static String mWhoami = new String("ImplB!");
+}
diff --git a/test/022-interface/src/ImplBSub.java b/test/022-interface/src/ImplBSub.java
new file mode 100644 (file)
index 0000000..f3a7714
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Interface test.
+ */
+public class ImplBSub extends ImplB implements /*Iface2,*/ Iface2Sub1 {
+
+    public int iFunc1(int ii) {
+        return ii+100;
+    }
+    public int iFunc2(int ii) {
+        return ii+200;
+    }
+}
diff --git a/test/022-interface/src/Main.java b/test/022-interface/src/Main.java
new file mode 100644 (file)
index 0000000..9151e89
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * test calling through an interface
+ */
+public class Main {
+    public static void main(String args[]) {
+        int result = 0;
+        Iface2Sub1 faceObj;
+        ImplA faceObj2;
+
+        faceObj = new ImplBSub();
+
+        result = faceObj.iFunc2(5);
+        System.out.print("ImplBSub intf: ");
+        System.out.println(result);
+
+        faceObj2 = new ImplA();
+        result = faceObj2.iFunc2(5);
+        System.out.print("ImplA: ");
+        System.out.println(result);
+    }
+}
diff --git a/test/023-many-interfaces/build b/test/023-many-interfaces/build
new file mode 100644 (file)
index 0000000..fc81d62
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# 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.
+
+# Stop if something fails.
+set -e
+
+# Write out a bunch of interface source files.
+gcc -o iface-gen iface-gen.c
+./iface-gen
+
+mkdir classes
+${JAVAC} -d classes src/*.java
+
+dx --debug --dex --dump-to=classes.lst --output=classes.dex classes
+zip test.jar classes.dex
diff --git a/test/023-many-interfaces/expected.txt b/test/023-many-interfaces/expected.txt
new file mode 100644 (file)
index 0000000..c6a0c61
--- /dev/null
@@ -0,0 +1,9 @@
+testIface001: done
+testIface049: done
+testIface099: done
+testVirt001: done
+testVirt049: done
+testVirt099: done
+testInst001: done
+testInst049: done
+testInst099: done
diff --git a/test/023-many-interfaces/iface-gen.c b/test/023-many-interfaces/iface-gen.c
new file mode 100644 (file)
index 0000000..1e3284a
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Android Open Source Project
+ *
+ * Generate a big pile of interface classes.
+ */
+#include <stdio.h>
+
+/*
+ * Create N interface files.
+ */
+static int createFiles(int count)
+{
+    FILE* fp;
+    int i;
+
+    for (i = 0; i < count; i++) {
+        char nameBuf[32];
+
+        sprintf(nameBuf, "src/Interface%03d.java", i);
+        fp = fopen(nameBuf, "w");
+        if (fp == NULL) {
+            fprintf(stderr, "ERROR: unable to open %s\n", nameBuf);
+            return -1;
+        }
+
+        fprintf(fp, "interface Interface%03d {\n", i);
+        if ((i & 0x01) != 0)
+            fprintf(fp, "    int func%03d();\n", i);
+        fprintf(fp, "}\n");
+        fclose(fp);
+    }
+
+    fp = fopen("func-decl", "w");
+    fprintf(fp, "    implements\n");
+    for (i = 0; i < count; i++) {
+        fprintf(fp, "        Interface%03d%s\n", i, (i == count-1) ? "" : ",");
+    }
+    fprintf(fp, "\n");
+    for (i = 1; i < count; i += 2) {
+        fprintf(fp, "    public int func%03d() { return %d; }\n", i, i);
+    }
+    fclose(fp);
+
+    return 0;
+}
+
+int main()
+{
+    int result;
+
+    result = createFiles(100);
+
+    return (result != 0);
+}
diff --git a/test/023-many-interfaces/info.txt b/test/023-many-interfaces/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/023-many-interfaces/src/Main.java b/test/023-many-interfaces/src/Main.java
new file mode 100644 (file)
index 0000000..666a41c
--- /dev/null
@@ -0,0 +1,6 @@
+public class Main {
+    static public void main(String[] args) throws Exception {
+        boolean timing = (args.length >= 1) && args[0].equals("--timing");
+        ManyInterfaces.run(timing);
+    }
+}
diff --git a/test/023-many-interfaces/src/ManyInterfaces.java b/test/023-many-interfaces/src/ManyInterfaces.java
new file mode 100644 (file)
index 0000000..375938a
--- /dev/null
@@ -0,0 +1,413 @@
+// Copyright 2007 The Android Open Source Project
+
+/*
+Initial:
+test001: 2039901us  (4079ns per call)
+test049: 3346619us  (6693ns per call)
+test099: 4687402us  (9374ns per call)
+testInst001: 1327216us  (2654ns per use)
+testInst049: 1326995us  (2653ns per use)
+testInst099: 1327735us  (2655ns per use)
+
+After refactoring cache code: 2871ns per use
+After re-refactoring cache code: 2797ns per use
+
+After de-inlining invoke-interface:
+test001: 2164873us  (4329ns per call)
+test049: 3303884us  (6607ns per call)
+test099: 4656718us  (9313ns per call)
+testInst001: 1401731us  (2803ns per use)
+testInst049: 1401120us  (2802ns per use)
+testInst099: 1401298us  (2802ns per use)
+
+After adding caching for invoke-interface:
+testIface001: 1909330us  (3818ns per call)
+testIface049: 1905204us  (3810ns per call)
+testIface099: 1899012us  (3798ns per call)
+testVirt001: 1825001us  (3650ns per call)
+testVirt049: 1826161us  (3652ns per call)
+testVirt099: 1823915us  (3647ns per call)
+testInst001: 1393963us  (2787ns per use)
+testInst049: 1393163us  (2786ns per use)
+testInst099: 1390496us  (2780ns per use)
+
+After repeating each operation 16 times inside the inner loop:
+testIface001: 1429472us  (2726ns per call)      * 2382ns
+testIface049: 1427847us  (2723ns per call)      * 2396ns
+testIface099: 1423707us  (2715ns per call)      * 2387ns
+testVirt001: 1277790us  (2437ns per call)       * 2118ns
+testVirt049: 1280276us  (2441ns per call)       * 2119ns
+testVirt099: 1272640us  (2427ns per call)       * 2118ns
+testInst001: 844694us  (1611ns per use)         * 1396ns
+testInst049: 845619us  (1612ns per use)         * 1395ns
+testInst099: 845526us  (1612ns per use)         * 1394ns
+('*' is with dx optimizations enabled)
+*/
+
+/**
+ * Semi-generated class with many interfaces.
+ */
+public class ManyInterfaces
+    implements
+        Interface000,
+        Interface001,
+        Interface002,
+        Interface003,
+        Interface004,
+        Interface005,
+        Interface006,
+        Interface007,
+        Interface008,
+        Interface009,
+        Interface010,
+        Interface011,
+        Interface012,
+        Interface013,
+        Interface014,
+        Interface015,
+        Interface016,
+        Interface017,
+        Interface018,
+        Interface019,
+        Interface020,
+        Interface021,
+        Interface022,
+        Interface023,
+        Interface024,
+        Interface025,
+        Interface026,
+        Interface027,
+        Interface028,
+        Interface029,
+        Interface030,
+        Interface031,
+        Interface032,
+        Interface033,
+        Interface034,
+        Interface035,
+        Interface036,
+        Interface037,
+        Interface038,
+        Interface039,
+        Interface040,
+        Interface041,
+        Interface042,
+        Interface043,
+        Interface044,
+        Interface045,
+        Interface046,
+        Interface047,
+        Interface048,
+        Interface049,
+        Interface050,
+        Interface051,
+        Interface052,
+        Interface053,
+        Interface054,
+        Interface055,
+        Interface056,
+        Interface057,
+        Interface058,
+        Interface059,
+        Interface060,
+        Interface061,
+        Interface062,
+        Interface063,
+        Interface064,
+        Interface065,
+        Interface066,
+        Interface067,
+        Interface068,
+        Interface069,
+        Interface070,
+        Interface071,
+        Interface072,
+        Interface073,
+        Interface074,
+        Interface075,
+        Interface076,
+        Interface077,
+        Interface078,
+        Interface079,
+        Interface080,
+        Interface081,
+        Interface082,
+        Interface083,
+        Interface084,
+        Interface085,
+        Interface086,
+        Interface087,
+        Interface088,
+        Interface089,
+        Interface090,
+        Interface091,
+        Interface092,
+        Interface093,
+        Interface094,
+        Interface095,
+        Interface096,
+        Interface097,
+        Interface098,
+        Interface099
+{
+    /** whether to report timing information */
+    private static boolean timing = false;
+
+    /**
+     * Report on a section.
+     */
+    private static void report(String label, long start, long end, int iter,
+            int rept) {
+        if (timing) {
+            System.out.println(label + ": " + (end - start) / 1000 + "us"
+                    + "  (" + (end - start) / (iter*rept) + "ns per call)");
+        } else {
+            System.out.println(label + ": done");
+        }
+    }
+
+    /**
+     * Run tests.
+     *
+     * @param timing whether to print out timing info
+     */
+    public static void run(boolean timing) {
+        ManyInterfaces.timing = timing;
+        ManyInterfaces obj = new ManyInterfaces();
+        Interface001 one;
+        Interface049 forty;
+        Interface099 ninety;
+        long start, end;
+        int iter = 32768;
+        int rept = 16;
+        int i;
+
+        /*
+         * Clear the heap.  The various classes involved should already
+         * be loaded and ready as a result of instantiating ManyInterfaces.
+         */
+        System.gc();
+
+        start = System.nanoTime();
+        testIface001(obj, iter);
+        end = System.nanoTime();
+        report("testIface001", start, end, iter, rept);
+
+        start = System.nanoTime();
+        testIface049(obj, iter);
+        end = System.nanoTime();
+        report("testIface049", start, end, iter, rept);
+
+        start = System.nanoTime();
+        testIface099(obj, iter);
+        end = System.nanoTime();
+        report("testIface099", start, end, iter, rept);
+
+        start = System.nanoTime();
+        testVirt001(obj, iter);
+        end = System.nanoTime();
+        report("testVirt001", start, end, iter, rept);
+
+        start = System.nanoTime();
+        testVirt049(obj, iter);
+        end = System.nanoTime();
+        report("testVirt049", start, end, iter, rept);
+
+        start = System.nanoTime();
+        testVirt099(obj, iter);
+        end = System.nanoTime();
+        report("testVirt099", start, end, iter, rept);
+
+        start = System.nanoTime();
+        testInstance001(obj, iter);
+        end = System.nanoTime();
+        report("testInst001", start, end, iter, rept);
+
+        start = System.nanoTime();
+        testInstance049(obj, iter);
+        end = System.nanoTime();
+        report("testInst049", start, end, iter, rept);
+
+        start = System.nanoTime();
+        testInstance099(obj, iter);
+        end = System.nanoTime();
+        report("testInst099", start, end, iter, rept);
+    }
+
+    public int func001() { return 1; }
+    public int func003() { return 3; }
+    public int func005() { return 5; }
+    public int func007() { return 7; }
+    public int func009() { return 9; }
+    public int func011() { return 11; }
+    public int func013() { return 13; }
+    public int func015() { return 15; }
+    public int func017() { return 17; }
+    public int func019() { return 19; }
+    public int func021() { return 21; }
+    public int func023() { return 23; }
+    public int func025() { return 25; }
+    public int func027() { return 27; }
+    public int func029() { return 29; }
+    public int func031() { return 31; }
+    public int func033() { return 33; }
+    public int func035() { return 35; }
+    public int func037() { return 37; }
+    public int func039() { return 39; }
+    public int func041() { return 41; }
+    public int func043() { return 43; }
+    public int func045() { return 45; }
+    public int func047() { return 47; }
+    public int func049() { return 49; }
+    public int func051() { return 51; }
+    public int func053() { return 53; }
+    public int func055() { return 55; }
+    public int func057() { return 57; }
+    public int func059() { return 59; }
+    public int func061() { return 61; }
+    public int func063() { return 63; }
+    public int func065() { return 65; }
+    public int func067() { return 67; }
+    public int func069() { return 69; }
+    public int func071() { return 71; }
+    public int func073() { return 73; }
+    public int func075() { return 75; }
+    public int func077() { return 77; }
+    public int func079() { return 79; }
+    public int func081() { return 81; }
+    public int func083() { return 83; }
+    public int func085() { return 85; }
+    public int func087() { return 87; }
+    public int func089() { return 89; }
+    public int func091() { return 91; }
+    public int func093() { return 93; }
+    public int func095() { return 95; }
+    public int func097() { return 97; }
+    public int func099() { return 99; }
+
+    static void testIface001(Interface001 iface, int count) {
+        while (count-- != 0) {
+            iface.func001(); iface.func001(); iface.func001(); iface.func001();
+            iface.func001(); iface.func001(); iface.func001(); iface.func001();
+            iface.func001(); iface.func001(); iface.func001(); iface.func001();
+            iface.func001(); iface.func001(); iface.func001(); iface.func001();
+        }
+    }
+
+    static void testIface049(Interface049 iface, int count) {
+        while (count-- != 0) {
+            iface.func049(); iface.func049(); iface.func049(); iface.func049();
+            iface.func049(); iface.func049(); iface.func049(); iface.func049();
+            iface.func049(); iface.func049(); iface.func049(); iface.func049();
+            iface.func049(); iface.func049(); iface.func049(); iface.func049();
+        }
+    }
+
+    static void testIface099(Interface099 iface, int count) {
+        while (count-- != 0) {
+            iface.func099(); iface.func099(); iface.func099(); iface.func099();
+            iface.func099(); iface.func099(); iface.func099(); iface.func099();
+            iface.func099(); iface.func099(); iface.func099(); iface.func099();
+            iface.func099(); iface.func099(); iface.func099(); iface.func099();
+        }
+    }
+
+    static void testVirt001(ManyInterfaces obj, int count) {
+        while (count-- != 0) {
+            obj.func001(); obj.func001(); obj.func001(); obj.func001();
+            obj.func001(); obj.func001(); obj.func001(); obj.func001();
+            obj.func001(); obj.func001(); obj.func001(); obj.func001();
+            obj.func001(); obj.func001(); obj.func001(); obj.func001();
+        }
+    }
+
+    static void testVirt049(ManyInterfaces obj, int count) {
+        while (count-- != 0) {
+            obj.func049(); obj.func049(); obj.func049(); obj.func049();
+            obj.func049(); obj.func049(); obj.func049(); obj.func049();
+            obj.func049(); obj.func049(); obj.func049(); obj.func049();
+            obj.func049(); obj.func049(); obj.func049(); obj.func049();
+        }
+    }
+
+    static void testVirt099(ManyInterfaces obj, int count) {
+        while (count-- != 0) {
+            obj.func099(); obj.func099(); obj.func099(); obj.func099();
+            obj.func099(); obj.func099(); obj.func099(); obj.func099();
+            obj.func099(); obj.func099(); obj.func099(); obj.func099();
+            obj.func099(); obj.func099(); obj.func099(); obj.func099();
+        }
+    }
+
+    static void testInstance001(Object obj, int count) {
+        if (!(obj instanceof Interface001))
+            System.err.println("BAD");
+        while (count-- != 0) {
+            boolean is;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+            is = obj instanceof Interface001;
+        }
+    }
+
+    static void testInstance049(Object obj, int count) {
+        if (!(obj instanceof Interface049))
+            System.err.println("BAD");
+        while (count-- != 0) {
+            boolean is;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+            is = obj instanceof Interface049;
+        }
+    }
+
+    static void testInstance099(Object obj, int count) {
+        if (!(obj instanceof Interface099))
+            System.err.println("BAD");
+        while (count-- != 0) {
+            boolean is;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+            is = obj instanceof Interface099;
+        }
+    }
+}
diff --git a/test/024-illegal-access/expected.txt b/test/024-illegal-access/expected.txt
new file mode 100644 (file)
index 0000000..5f951f4
--- /dev/null
@@ -0,0 +1,2 @@
+Got expected failure 1
+Got expected failure 2
diff --git a/test/024-illegal-access/info.txt b/test/024-illegal-access/info.txt
new file mode 100644 (file)
index 0000000..16a284d
--- /dev/null
@@ -0,0 +1,3 @@
+Test that an attempt to access a private field results in a verification
+error.  Also try to access a non-public class in a different package with
+"instanceof".
diff --git a/test/024-illegal-access/src/CheckInstanceof.java b/test/024-illegal-access/src/CheckInstanceof.java
new file mode 100644 (file)
index 0000000..de48cd2
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+/**
+ * Make sure we're performing access checks on classes used in "instanceof".
+ */
+public class CheckInstanceof {
+    public static void main(Object obj) {
+        if (obj instanceof otherpkg.Package)
+            System.out.println("yes!");
+        else
+            System.out.println("no!");
+    }
+}
diff --git a/test/024-illegal-access/src/Main.java b/test/024-illegal-access/src/Main.java
new file mode 100644 (file)
index 0000000..bde73e9
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Main {
+    static public void main(String[] args) {
+        try {
+            PublicAccess.main();
+            System.err.println("ERROR: call 1 not expected to succeed");
+        } catch (VerifyError ve) {
+            // dalvik
+            System.out.println("Got expected failure 1");
+        } catch (IllegalAccessError iae) {
+            // reference
+            System.out.println("Got expected failure 1");
+        }
+
+        try {
+            CheckInstanceof.main(new Object());
+            System.err.println("ERROR: call 2 not expected to succeed");
+        } catch (VerifyError ve) {
+            // dalvik
+            System.out.println("Got expected failure 2");
+        } catch (IllegalAccessError iae) {
+            // reference
+            System.out.println("Got expected failure 2");
+        }
+    }
+}
diff --git a/test/024-illegal-access/src/PublicAccess.java b/test/024-illegal-access/src/PublicAccess.java
new file mode 100644 (file)
index 0000000..fdc0e9e
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Some stuff for access checks.
+ */
+public class PublicAccess {
+    public static void main() {
+        String shouldFail = SemiPrivate.mPrivvy;
+        System.out.println("Got " + shouldFail);
+    }
+}
diff --git a/test/024-illegal-access/src/SemiPrivate.java b/test/024-illegal-access/src/SemiPrivate.java
new file mode 100644 (file)
index 0000000..17b2ac0
--- /dev/null
@@ -0,0 +1,8 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Version with package scope access.
+ */
+public class SemiPrivate {
+    /* not private */ static String mPrivvy = "stuff";
+}
diff --git a/test/024-illegal-access/src/otherpkg/Package.java b/test/024-illegal-access/src/otherpkg/Package.java
new file mode 100644 (file)
index 0000000..bc295b5
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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 otherpkg;
+
+/*
+ * Package-scope class (public here).
+ */
+public class Package {
+}
diff --git a/test/024-illegal-access/src2/SemiPrivate.java b/test/024-illegal-access/src2/SemiPrivate.java
new file mode 100644 (file)
index 0000000..cf6f8e6
--- /dev/null
@@ -0,0 +1,8 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Version with private access.
+ */
+public class SemiPrivate {
+    private static String mPrivvy = "stuff";
+}
diff --git a/test/024-illegal-access/src2/otherpkg/Package.java b/test/024-illegal-access/src2/otherpkg/Package.java
new file mode 100644 (file)
index 0000000..54d8341
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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 otherpkg;
+
+/*
+ * Package-scope class.
+ */
+class Package {
+}
diff --git a/test/025-access-controller/expected.txt b/test/025-access-controller/expected.txt
new file mode 100644 (file)
index 0000000..75cfc99
--- /dev/null
@@ -0,0 +1 @@
+AccessControllerTest: got 39
diff --git a/test/025-access-controller/info.txt b/test/025-access-controller/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/025-access-controller/src/Main.java b/test/025-access-controller/src/Main.java
new file mode 100644 (file)
index 0000000..84dc057
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2007 The Android Open Source Project
+
+import java.security.AccessController;
+
+/**
+ * Test java.security.AccessController.
+ */
+public class Main {
+    public static void main(String[] args) {
+        Privvy priv = new Privvy(38);
+        Integer result = AccessController.doPrivileged(priv);
+        System.out.println("AccessControllerTest: got " + result);
+    }
+}
diff --git a/test/025-access-controller/src/Privvy.java b/test/025-access-controller/src/Privvy.java
new file mode 100644 (file)
index 0000000..07a0678
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2007 The Android Open Source Project
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
+
+class Privvy implements PrivilegedAction<Integer> {
+
+    private Integer mValue;
+
+    public Privvy(int val) {
+        mValue = new Integer(val + 1);
+    }
+
+    public Integer run() {
+        return mValue;
+    }
+}
diff --git a/test/026-access/expected.txt b/test/026-access/expected.txt
new file mode 100644 (file)
index 0000000..dabfb37
--- /dev/null
@@ -0,0 +1,2 @@
+access test
+Blort.
diff --git a/test/026-access/info.txt b/test/026-access/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/026-access/src/Main.java b/test/026-access/src/Main.java
new file mode 100644 (file)
index 0000000..9628259
--- /dev/null
@@ -0,0 +1,12 @@
+// Copyright 2006 The Android Open Source Project
+
+import otherpackage.PublicAccess;
+
+public class Main {
+    public static void main(String[] args) {
+        System.out.println("access test");
+
+        PublicAccess pa = new PublicAccess();
+        pa.main();
+    }
+}
diff --git a/test/026-access/src/otherpackage/PublicAccess.java b/test/026-access/src/otherpackage/PublicAccess.java
new file mode 100644 (file)
index 0000000..996fa76
--- /dev/null
@@ -0,0 +1,7 @@
+package otherpackage;
+
+public class PublicAccess {
+    static public void main() {
+        System.out.println("Blort.");
+    }
+}
diff --git a/test/027-arithmetic/expected.txt b/test/027-arithmetic/expected.txt
new file mode 100644 (file)
index 0000000..2dadf10
--- /dev/null
@@ -0,0 +1,18 @@
+f=1234.5677 --> i=1234
+f=-1234.5677 --> i=-1234
+d=1234.5678 --> i=1234
+d=-1234.5678 --> i=-1234
+d=5.6789567890123E9 --> l=5678956789
+d=-5.6789567890123E9 --> l=-5678956789
+i=7654 --> l=7654
+i=-7654 --> l=-7654
+l=5678956789 --> i=1383989493
+l=-5678956789 --> i=-1383989493
+i=1234 --> f=1234.0
+i=-1234 --> f=-1234.0
+values are 44332211 and bbaa9988
+First l is bbaa998844332211
+Second l is bbaa998844332211
+shiftTest2 l is 1122334455667788
+b=-1, s=-1, c=4095, i=268435455
+b=0xffffffff, s=0xffffffff, c=0xfff, i=0xfffffff
diff --git a/test/027-arithmetic/info.txt b/test/027-arithmetic/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/027-arithmetic/src/Main.java b/test/027-arithmetic/src/Main.java
new file mode 100644 (file)
index 0000000..4d0f74e
--- /dev/null
@@ -0,0 +1,141 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Test arithmetic operations.
+ */
+public class Main {
+
+    static void shiftTest1()
+    {
+        final int[] mBytes = {
+            0x11, 0x22, 0x33, 0x44, 0x88, 0x99, 0xaa, 0xbb
+        };
+        long l;
+        int i1, i2;
+
+        i1 = mBytes[0] | mBytes[1] << 8 | mBytes[2] << 16 | mBytes[3] << 24;
+        i2 = mBytes[4] | mBytes[5] << 8 | mBytes[6] << 16 | mBytes[7] << 24;
+        l = i1 | ((long)i2 << 32);
+
+       System.out.println("values are " + Integer.toHexString(i1)
+           + " and " + Integer.toHexString(i2));
+
+        System.out.println("First l is " + Long.toHexString(l));
+
+        l = (long)mBytes[0]
+            | (long)mBytes[1] << 8
+            | (long)mBytes[2] << 16
+            | (long)mBytes[3] << 24
+            | (long)mBytes[4] << 32
+            | (long)mBytes[5] << 40
+            | (long)mBytes[6] << 48
+            | (long)mBytes[7] << 56;
+
+        System.out.println("Second l is " + Long.toHexString(l));
+    }
+
+    static void shiftTest2()
+    {
+        long    a = 0x11;
+        long    b = 0x22;
+        long    c = 0x33;
+        long    d = 0x44;
+        long    e = 0x55;
+        long    f = 0x66;
+        long    g = 0x77;
+        long    h = 0x88;
+
+        long    result = ((a << 56) | (b << 48) | (c << 40) | (d << 32) |
+                         (e << 24) | (f << 16) | (g << 8) | h);
+
+        System.out.println("shiftTest2 l is " + Long.toHexString(result));
+    }
+
+    static void convTest()
+    {
+        float f;
+        double d;
+        int i;
+        long l;
+
+        /* float --> int */
+        f = 1234.5678f;
+        i = (int) f;
+        System.out.println("f=" + f + " --> i=" + i);
+
+        f = -1234.5678f;
+        i = (int) f;
+        System.out.println("f=" + f + " --> i=" + i);
+
+        /* double --> int */
+        d = 1234.5678;
+        i = (int) d;
+        System.out.println("d=" + d + " --> i=" + i);
+
+        d = -1234.5678;
+        i = (int) d;
+        System.out.println("d=" + d + " --> i=" + i);
+
+        /* double --> long */
+        d = 5678956789.0123;
+        l = (long) d;
+        System.out.println("d=" + d + " --> l=" + l);
+
+        d = -5678956789.0123;
+        l = (long) d;
+        System.out.println("d=" + d + " --> l=" + l);
+
+        /* int --> long */
+        i = 7654;
+        l = (long) i;
+        System.out.println("i=" + i + " --> l=" + l);
+
+        i = -7654;
+        l = (long) i;
+        System.out.println("i=" + i + " --> l=" + l);
+
+        /* long --> int (with truncation) */
+        l = 5678956789L;
+        i = (int) l;
+        System.out.println("l=" + l + " --> i=" + i);
+
+        l = -5678956789L;
+        i = (int) l;
+        System.out.println("l=" + l + " --> i=" + i);
+
+        /* int --> float */
+        i = 1234;
+        f = (float) i;
+        System.out.println("i=" + i + " --> f=" + f);
+
+        i = -1234;
+        f = (float) i;
+        System.out.println("i=" + i + " --> f=" + f);
+    }
+
+    static void unsignedShiftTest()
+    {
+        byte b = -4;
+        short s = -4;
+        char c = 0xfffc;
+        int i = -4;
+
+        b >>>= 4;
+        s >>>= 4;
+        c >>>= 4;
+        i >>>= 4;
+
+        System.out.println("b=" + b + ", s=" + s + ", c=" + (int)c + ", i=" +i);
+        System.out.println("b=0x" + Integer.toHexString((int)b)
+            + ", s=0x" + Integer.toHexString((int)s)
+            + ", c=0x" + Integer.toHexString((int)c)
+            + ", i=0x" + Integer.toHexString(i));
+    }
+
+    public static void main(String[] args) {
+        convTest();
+        shiftTest1();
+        shiftTest2();
+        unsignedShiftTest();
+    }
+}
diff --git a/test/028-array-write/expected.txt b/test/028-array-write/expected.txt
new file mode 100644 (file)
index 0000000..85986b5
--- /dev/null
@@ -0,0 +1,3 @@
+Running writeTest...
+Running copyTest...
+Done!
diff --git a/test/028-array-write/info.txt b/test/028-array-write/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/028-array-write/src/Main.java b/test/028-array-write/src/Main.java
new file mode 100644 (file)
index 0000000..6f36f84
--- /dev/null
@@ -0,0 +1,68 @@
+// Copyright 2007 The Android Open Source Project
+
+/**
+ * Array write speed test.
+ */
+public class Main {
+    /** whether to report times */
+    static boolean timing = false;
+
+    static final int STORAGE_SIZE = 128*1024;
+    static int[] mStorage = new int[STORAGE_SIZE];
+
+    static public void report(long start, long end) {
+        if (! timing) {
+            return;
+        }
+
+        System.out.println("Finished in " + ((end - start) / 1000000.0)
+            + " msec");
+    }
+
+    static void writeArray(int val) {
+        for (int i = STORAGE_SIZE-1; i >= 0; i--)
+            mStorage[i] = val;
+    }
+
+    static void writeTest() {
+        long start, end;
+
+        writeArray(0);  // touch all the memory
+
+        System.out.println("Running writeTest...");
+        start = System.nanoTime();
+        for (int i = 1; i < 20; i++)
+            writeArray(i);
+        end = System.nanoTime();
+
+        report(start, end);
+    }
+
+    static void copyTest() {
+        long start, end;
+
+        // touch once
+        System.arraycopy(mStorage, 0, mStorage,
+            STORAGE_SIZE/2, STORAGE_SIZE/2);
+
+        System.out.println("Running copyTest...");
+        start = System.nanoTime();
+        for (int i = 1; i < 35; i++) {
+            System.arraycopy(mStorage, 0, mStorage,
+                STORAGE_SIZE/2, STORAGE_SIZE/2);
+        }
+        end = System.nanoTime();
+
+        report(start, end);
+    }
+
+    public static void main(String[] args) {
+        if ((args.length >= 1) && args[0].equals("--timing")) {
+            timing = true;
+        }
+
+        writeTest();
+        copyTest();
+        System.out.println("Done!");
+    }
+}
diff --git a/test/029-assert/expected.txt b/test/029-assert/expected.txt
new file mode 100644 (file)
index 0000000..bf0efec
--- /dev/null
@@ -0,0 +1 @@
+caught expected assert exception
diff --git a/test/029-assert/info.txt b/test/029-assert/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/029-assert/src/Main.java b/test/029-assert/src/Main.java
new file mode 100644 (file)
index 0000000..1e5cc7c
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2007 The Android Open Source Project
+
+/**
+ * Test Java language asserts.
+ */
+public class Main {
+    public static void main(String[] args) {
+        assert true;
+        try {
+            assert false;
+            System.out.println("GLITCH: didn't assert (is '-ea' set?)");
+        } catch (AssertionError ae) {
+            System.out.println("caught expected assert exception");
+        }
+    }
+}
diff --git a/test/030-bad-finalizer/expected.txt b/test/030-bad-finalizer/expected.txt
new file mode 100644 (file)
index 0000000..88b1896
--- /dev/null
@@ -0,0 +1,7 @@
+Constructed object.
+Nulled. Requestion gc.
+Finalizer started and spinning...
+Finalizer done spinning.
+Finalizer sleeping forever now.
+Requesting another GC.
+Requesting another GC.
diff --git a/test/030-bad-finalizer/info.txt b/test/030-bad-finalizer/info.txt
new file mode 100644 (file)
index 0000000..26f4993
--- /dev/null
@@ -0,0 +1,15 @@
+The finalizer for this class never finishes.  Dalvik is expected to detect
+this situation and abort the VM (so you will likely see a stacktrace like
+the following in the log output).
+
+java.util.concurrent.TimeoutException
+       at java.lang.VMThread.sleep(Native Method)
+       at java.lang.Thread.sleep(Thread.java:1031)
+       at java.lang.Thread.sleep(Thread.java:1013)
+       at BadFinalizer.snooze(BadFinalizer.java:9)
+       at BadFinalizer.finalize(BadFinalizer.java:29)
+       at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:182)
+       at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168)
+       at java.lang.Thread.run(Thread.java:856)
+Calling exit(2)
+
diff --git a/test/030-bad-finalizer/src/BadFinalizer.java b/test/030-bad-finalizer/src/BadFinalizer.java
new file mode 100644 (file)
index 0000000..3ff422b
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright 2007 The Android Open Source Project
+
+/**
+ * Class with a bad finalizer.
+ */
+public class BadFinalizer {
+    public static void snooze(int ms) {
+        try {
+            Thread.sleep(ms);
+        } catch (InterruptedException ie) {
+            System.out.println("Snooze: " + ie.getMessage());
+        }
+    }
+
+    protected void finalize() {
+        System.out.println("Finalizer started and spinning...");
+        int j = 0;
+
+        /* spin for a bit */
+        long start, end;
+        start = System.nanoTime();
+        for (int i = 0; i < 1000000; i++)
+            j++;
+        end = System.nanoTime();
+        System.out.println("Finalizer done spinning.");
+
+        System.out.println("Finalizer sleeping forever now.");
+        while (true) {
+            snooze(10000);
+        }
+    }
+}
diff --git a/test/030-bad-finalizer/src/Main.java b/test/030-bad-finalizer/src/Main.java
new file mode 100644 (file)
index 0000000..c063476
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright 2007 The Android Open Source Project
+
+/**
+ * Test a class with a bad finalizer.
+ */
+public class Main {
+    public static void main(String[] args) {
+        BadFinalizer bf = new BadFinalizer();
+
+        System.out.println("Constructed object.");
+        bf = null;
+
+        System.out.println("Nulled. Requestion gc.");
+        System.gc();
+
+        for (int i = 0; i < 8; i++) {
+            BadFinalizer.snooze(5000);
+            System.out.println("Requesting another GC.");
+            System.gc();
+        }
+
+        System.out.println("Done waiting.");
+        System.exit(0);
+    }
+}
diff --git a/test/031-class-attributes/expected.txt b/test/031-class-attributes/expected.txt
new file mode 100644 (file)
index 0000000..47eaeee
--- /dev/null
@@ -0,0 +1,164 @@
+***** class ClassAttrs:
+  name: ClassAttrs
+  canonical: ClassAttrs
+  simple: ClassAttrs
+  genericSignature: null
+  super: class java.lang.Object
+  declaring: null
+  enclosing: null
+  enclosingCon: null
+  enclosingMeth: null
+  modifiers: 1
+  package: null
+  declaredClasses: [2] class ClassAttrs$PublicMemberClass, class ClassAttrs$MemberClass
+  member classes: [1] class ClassAttrs$PublicMemberClass
+  isAnnotation: false
+  isAnonymous: false
+  isArray: false
+  isEnum: false
+  isInterface: false
+  isLocalClass: false
+  isMemberClass: false
+  isPrimitive: false
+  isSynthetic: false
+***** class OtherClass:
+  name: OtherClass
+  canonical: OtherClass
+  simple: OtherClass
+  genericSignature: null
+  super: class java.lang.Object
+  declaring: null
+  enclosing: null
+  enclosingCon: null
+  enclosingMeth: null
+  modifiers: 0
+  package: null
+  declaredClasses: [0]
+  member classes: [0]
+  isAnnotation: false
+  isAnonymous: false
+  isArray: false
+  isEnum: false
+  isInterface: false
+  isLocalClass: false
+  isMemberClass: false
+  isPrimitive: false
+  isSynthetic: false
+***** class otherpackage.OtherPackageClass:
+  name: otherpackage.OtherPackageClass
+  canonical: otherpackage.OtherPackageClass
+  simple: OtherPackageClass
+  genericSignature: null
+  super: class java.lang.Object
+  declaring: null
+  enclosing: null
+  enclosingCon: null
+  enclosingMeth: null
+  modifiers: 1
+  package: package otherpackage
+  declaredClasses: [0]
+  member classes: [0]
+  isAnnotation: false
+  isAnonymous: false
+  isArray: false
+  isEnum: false
+  isInterface: false
+  isLocalClass: false
+  isMemberClass: false
+  isPrimitive: false
+  isSynthetic: false
+***** class ClassAttrs$1InnerNamed:
+  name: ClassAttrs$1InnerNamed
+  canonical: null
+  simple: InnerNamed
+  genericSignature: null
+  super: class java.lang.Object
+  declaring: null
+  enclosing: class ClassAttrs
+  enclosingCon: null
+  enclosingMeth: public static void ClassAttrs.main()
+  modifiers: 0
+  package: null
+  declaredClasses: [0]
+  member classes: [0]
+  isAnnotation: false
+  isAnonymous: false
+  isArray: false
+  isEnum: false
+  isInterface: false
+  isLocalClass: true
+  isMemberClass: false
+  isPrimitive: false
+  isSynthetic: false
+***** class ClassAttrs$1ConsInnerNamed:
+  name: ClassAttrs$1ConsInnerNamed
+  canonical: null
+  simple: ConsInnerNamed
+  genericSignature: null
+  super: class java.lang.Object
+  declaring: null
+  enclosing: class ClassAttrs
+  enclosingCon: ClassAttrs()
+  enclosingMeth: null
+  modifiers: 0
+  package: null
+  declaredClasses: [0]
+  member classes: [0]
+  isAnnotation: false
+  isAnonymous: false
+  isArray: false
+  isEnum: false
+  isInterface: false
+  isLocalClass: true
+  isMemberClass: false
+  isPrimitive: false
+  isSynthetic: false
+***** class ClassAttrs$1:
+  name: ClassAttrs$1
+  canonical: null
+  simple: 
+  genericSignature: null
+  super: class OtherClass
+  declaring: null
+  enclosing: class ClassAttrs
+  enclosingCon: null
+  enclosingMeth: public static void ClassAttrs.main()
+  modifiers: 8
+  package: null
+  declaredClasses: [0]
+  member classes: [0]
+  isAnnotation: false
+  isAnonymous: true
+  isArray: false
+  isEnum: false
+  isInterface: false
+  isLocalClass: false
+  isMemberClass: false
+  isPrimitive: false
+  isSynthetic: false
+***** class ClassAttrs$MemberClass:
+  name: ClassAttrs$MemberClass
+  canonical: ClassAttrs.MemberClass
+  simple: MemberClass
+  genericSignature: <XYZ:Ljava/lang/Object;>Ljava/lang/Object;
+  super: class java.lang.Object
+  declaring: class ClassAttrs
+  enclosing: class ClassAttrs
+  enclosingCon: null
+  enclosingMeth: null
+  modifiers: 8
+  package: null
+  declaredClasses: [0]
+  member classes: [0]
+  isAnnotation: false
+  isAnonymous: false
+  isArray: false
+  isEnum: false
+  isInterface: false
+  isLocalClass: false
+  isMemberClass: true
+  isPrimitive: false
+  isSynthetic: false
+constructor signature: (LClassAttrs$MemberClass<TXYZ;>;)V
+method signature: ()Ljava/lang/Class<TXYZ;>;
+field signature: LClassAttrs$MemberClass<TXYZ;>;
diff --git a/test/031-class-attributes/info.txt b/test/031-class-attributes/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/031-class-attributes/src/ClassAttrs.java b/test/031-class-attributes/src/ClassAttrs.java
new file mode 100644 (file)
index 0000000..c1407bd
--- /dev/null
@@ -0,0 +1,201 @@
+import otherpackage.OtherPackageClass;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+
+public class ClassAttrs {
+    ClassAttrs() {
+        /* local, not anonymous, not member */
+        class ConsInnerNamed {
+            public void showMe() {
+                printClassAttrs(this.getClass());
+            }
+        }
+
+        ConsInnerNamed cinner = new ConsInnerNamed();
+        cinner.showMe();
+    }
+
+    public static void main() {
+        printClassAttrs(ClassAttrs.class);
+        printClassAttrs(OtherClass.class);
+        printClassAttrs(OtherPackageClass.class);
+
+        /* local, not anonymous, not member */
+        class InnerNamed {
+            public void showMe() {
+                printClassAttrs(this.getClass());
+            }
+        }
+        InnerNamed inner = new InnerNamed();
+        inner.showMe();
+
+        ClassAttrs attrs = new ClassAttrs();
+
+        /* anonymous, not local, not member */
+        printClassAttrs((new OtherClass() { int i = 5; }).getClass());
+
+        /* member, not anonymous, not local */
+        printClassAttrs(MemberClass.class);
+
+        try {
+            Constructor cons;
+            cons = MemberClass.class.getConstructor(
+                    new Class[] { MemberClass.class });
+            System.out.println("constructor signature: "
+                    + getSignatureAttribute(cons));
+
+            Method meth;
+            meth = MemberClass.class.getMethod("foo", (Class[]) null);
+            System.out.println("method signature: "
+                    + getSignatureAttribute(meth));
+
+            Field field;
+            field = MemberClass.class.getField("mWha");
+            System.out.println("field signature: "
+                    + getSignatureAttribute(field));
+        } catch (NoSuchMethodException nsme) {
+            System.err.println("FAILED: " + nsme);
+        } catch (NoSuchFieldException nsfe) {
+            System.err.println("FAILED: " + nsfe);
+        } catch (RuntimeException re) {
+            System.err.println("FAILED: " + re);
+            re.printStackTrace();
+        }
+    }
+
+    /* to call the (out-of-scope) <code>getSignatureAttribute</code> methods */
+    public static String getSignatureAttribute(Object obj) {
+        Method method;
+        try {
+            if (obj instanceof AccessibleObject) {
+                method = AccessibleObject.class.getDeclaredMethod(
+                        "getSignatureAttribute");
+            } else {
+                // Should be a Class.
+                method = Class.class.getDeclaredMethod(
+                        "getSignatureAttribute");
+            }
+            method.setAccessible(true);
+        } catch (NoSuchMethodException ex) {
+            System.err.println("getSignatureAttribute() not defined.");
+            ex.printStackTrace();
+            return "<unknown>";
+        }
+
+        try {
+            return (String) method.invoke(obj);
+        } catch (IllegalAccessException ex) {
+            throw new RuntimeException(ex);
+        } catch (InvocationTargetException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    /* for reflection testing */
+    static class MemberClass<XYZ> {
+        public MemberClass<XYZ> mWha;
+
+        public MemberClass(MemberClass<XYZ> memb) {
+            mWha = memb;
+        }
+
+        public Class<XYZ> foo() throws NoSuchMethodException {
+            return null;
+        }
+    }
+
+    /* for reflection testing (getClasses vs getDeclaredClasses) */
+    static public class PublicMemberClass {
+        float mBlah;
+    }
+
+    /*
+     * Dump a variety of class attributes.
+     */
+    public static void printClassAttrs(Class clazz) {
+        final boolean WORKING = false;
+        Class clazz2;
+
+        System.out.println("***** " + clazz + ":");
+
+        System.out.println("  name: "
+            + clazz.getName());
+        System.out.println("  canonical: "
+            + clazz.getCanonicalName());
+        System.out.println("  simple: "
+            + clazz.getSimpleName());
+        System.out.println("  genericSignature: "
+            + getSignatureAttribute(clazz));
+
+        System.out.println("  super: "
+            + clazz.getSuperclass());
+        if (WORKING) System.out.println("  genericSuperclass: "
+            + clazz.getGenericSuperclass());
+        System.out.println("  declaring: "
+            + clazz.getDeclaringClass());
+        System.out.println("  enclosing: "
+            + clazz.getEnclosingClass());
+        System.out.println("  enclosingCon: "
+            + clazz.getEnclosingConstructor());
+        System.out.println("  enclosingMeth: "
+            + clazz.getEnclosingMethod());
+        System.out.println("  modifiers: "
+            + clazz.getModifiers());
+        System.out.println("  package: "
+            + clazz.getPackage());
+
+        System.out.println("  declaredClasses: "
+            + stringifyTypeArray(clazz.getDeclaredClasses()));
+        System.out.println("  member classes: "
+            + stringifyTypeArray(clazz.getClasses()));
+
+        System.out.println("  isAnnotation: "
+            + clazz.isAnnotation());
+        System.out.println("  isAnonymous: "
+            + clazz.isAnonymousClass());
+        System.out.println("  isArray: "
+            + clazz.isArray());
+        System.out.println("  isEnum: "
+            + clazz.isEnum());
+        System.out.println("  isInterface: "
+            + clazz.isInterface());
+        System.out.println("  isLocalClass: "
+            + clazz.isLocalClass());
+        System.out.println("  isMemberClass: "
+            + clazz.isMemberClass());
+        System.out.println("  isPrimitive: "
+            + clazz.isPrimitive());
+        System.out.println("  isSynthetic: "
+            + clazz.isSynthetic());
+
+        if (WORKING) System.out.println("  genericInterfaces: "
+            + stringifyTypeArray(clazz.getGenericInterfaces()));
+    }
+
+    /*
+     * Convert an array of Type into a string.  Start with an array count.
+     */
+    private static String stringifyTypeArray(Type[] types) {
+        StringBuilder stb = new StringBuilder();
+        boolean first = true;
+
+        stb.append("[" + types.length + "]");
+
+        for (Type t: types) {
+            if (first) {
+                stb.append(" ");
+                first = false;
+            } else {
+                stb.append(", ");
+            }
+            stb.append(t.toString());
+        }
+
+        return stb.toString();
+    }
+}
diff --git a/test/031-class-attributes/src/Main.java b/test/031-class-attributes/src/Main.java
new file mode 100644 (file)
index 0000000..bc6b749
--- /dev/null
@@ -0,0 +1,5 @@
+public class Main {
+    public static void main(String[] args) {
+        ClassAttrs.main();
+    }
+}
diff --git a/test/031-class-attributes/src/OtherClass.java b/test/031-class-attributes/src/OtherClass.java
new file mode 100644 (file)
index 0000000..0b4526e
--- /dev/null
@@ -0,0 +1,2 @@
+class OtherClass {
+}
diff --git a/test/031-class-attributes/src/otherpackage/OtherPackageClass.java b/test/031-class-attributes/src/otherpackage/OtherPackageClass.java
new file mode 100644 (file)
index 0000000..9652b77
--- /dev/null
@@ -0,0 +1,4 @@
+package otherpackage;
+
+public class OtherPackageClass {
+}
diff --git a/test/032-concrete-sub/expected.txt b/test/032-concrete-sub/expected.txt
new file mode 100644 (file)
index 0000000..56f25bb
--- /dev/null
@@ -0,0 +1,6 @@
+calling abs.doStuff()
+In AbstractBase.doStuff (src2)
+Got expected exception from abs.doStuff().
+class modifiers=1025
+meth modifiers=1025
+Got expected failure
diff --git a/test/032-concrete-sub/info.txt b/test/032-concrete-sub/info.txt
new file mode 100644 (file)
index 0000000..1956994
--- /dev/null
@@ -0,0 +1,3 @@
+This tests some facets of abstract method handling, notably situations
+where a concrete class and its abstract superclass were compiled with
+different notions about which methods are abstract.
diff --git a/test/032-concrete-sub/src/AbstractBase.java b/test/032-concrete-sub/src/AbstractBase.java
new file mode 100644 (file)
index 0000000..6281189
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Abstract base class.
+ */
+public abstract class AbstractBase {
+    public void doStuff() {
+        System.out.println("In AbstractBase.doStuff");
+    }
+
+    public void abstractOrNot() {}
+}
diff --git a/test/032-concrete-sub/src/ConcreteSub.java b/test/032-concrete-sub/src/ConcreteSub.java
new file mode 100644 (file)
index 0000000..083f25d
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.reflect.Method;
+
+/**
+ * Test insertion of an abstract method in a superclass.
+ */
+public class ConcreteSub extends AbstractBase {
+    private static void callBase(AbstractBase abs) {
+        System.out.println("calling abs.doStuff()");
+        abs.doStuff();
+    }
+
+    public static void main() {
+        ConcreteSub sub = new ConcreteSub();
+
+        try {
+            callBase(sub);
+        } catch (AbstractMethodError ame) {
+            System.out.println("Got expected exception from abs.doStuff().");
+        }
+
+        /*
+         * Check reflection stuff.
+         */
+        Class absClass = AbstractBase.class;
+        Method meth;
+
+        System.out.println("class modifiers=" + absClass.getModifiers());
+
+        try {
+            meth = absClass.getMethod("redefineMe", (Class[]) null);
+        } catch (NoSuchMethodException nsme) {
+            nsme.printStackTrace();
+            return;
+        }
+        System.out.println("meth modifiers=" + meth.getModifiers());
+    }
+}
diff --git a/test/032-concrete-sub/src/ConcreteSub2.java b/test/032-concrete-sub/src/ConcreteSub2.java
new file mode 100644 (file)
index 0000000..0a9e67e
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+/**
+ * Test conversion of a concrete method to an abstract method.  This class
+ * will fail verification because there is no implementation of the
+ * abstractOrNot() method.
+ */
+public class ConcreteSub2 extends AbstractBase {
+    public void doStuff() {
+        abstractOrNot();
+    }
+}
diff --git a/test/032-concrete-sub/src/Main.java b/test/032-concrete-sub/src/Main.java
new file mode 100644 (file)
index 0000000..4a5193d
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Test insertion of an abstract method in a superclass.
+ */
+public class Main {
+    public static void main(String[] args) {
+        ConcreteSub.main();
+
+        try {
+            // Dalvik verifier stops here (VerifyError)
+            ConcreteSub2 blah = new ConcreteSub2();
+            // other VMs fail here (AbstractMethodError)
+            blah.doStuff();
+            System.err.println("Succeeded unexpectedly");
+        } catch (VerifyError ve) {
+            System.out.println("Got expected failure");
+        } catch (AbstractMethodError ame) {
+            System.out.println("Got expected failure");
+        }
+    }
+}
diff --git a/test/032-concrete-sub/src2/AbstractBase.java b/test/032-concrete-sub/src2/AbstractBase.java
new file mode 100644 (file)
index 0000000..534f738
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Abstract base class.
+ */
+public abstract class AbstractBase {
+    public void doStuff() {
+        System.out.println("In AbstractBase.doStuff (src2)");
+        redefineMe();
+    }
+
+    public abstract void redefineMe();
+
+    public abstract void abstractOrNot();
+}
diff --git a/test/033-class-init-deadlock/expected.txt b/test/033-class-init-deadlock/expected.txt
new file mode 100644 (file)
index 0000000..387a426
--- /dev/null
@@ -0,0 +1,7 @@
+Deadlock test starting.
+A initializing...
+B initializing...
+Deadlock test interupting threads.
+Deadlock test main thread bailing.
+A initialized: false
+B initialized: false
diff --git a/test/033-class-init-deadlock/info.txt b/test/033-class-init-deadlock/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/033-class-init-deadlock/src/Main.java b/test/033-class-init-deadlock/src/Main.java
new file mode 100644 (file)
index 0000000..27c4922
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * This causes most VMs to lock up.
+ *
+ * Interrupting threads in class initialization should NOT work.
+ */
+public class Main {
+    public static boolean aInitialized = false;
+    public static boolean bInitialized = false;
+
+    static public void main(String[] args) {
+        Thread thread1, thread2;
+
+        System.out.println("Deadlock test starting.");
+        thread1 = new Thread() { public void run() { new A(); } };
+        thread2 = new Thread() { public void run() { new B(); } };
+        thread1.start();
+        thread2.start();
+
+        try { Thread.sleep(6000); } catch (InterruptedException ie) { }
+
+        System.out.println("Deadlock test interupting threads.");
+        thread1.interrupt();
+        thread2.interrupt();
+        System.out.println("Deadlock test main thread bailing.");
+        System.out.println("A initialized: " + aInitialized);
+        System.out.println("B initialized: " + bInitialized);
+        System.exit(0);
+    }
+}
+
+class A {
+    static {
+        System.out.println("A initializing...");
+        try { Thread.sleep(3000); } catch (InterruptedException ie) { }
+        new B();
+        System.out.println("A initialized");
+        Main.aInitialized = true;
+    }
+}
+
+class B {
+    static {
+        System.out.println("B initializing...");
+        try { Thread.sleep(3000); } catch (InterruptedException ie) { }
+        new A();
+        System.out.println("B initialized");
+        Main.bInitialized = true;
+    }
+}
diff --git a/test/034-call-null/expected.txt b/test/034-call-null/expected.txt
new file mode 100644 (file)
index 0000000..5ffbe05
--- /dev/null
@@ -0,0 +1,3 @@
+java.lang.NullPointerException
+       at Main.main(Main.java:12)
+       at dalvik.system.NativeStart.main(Native Method)
diff --git a/test/034-call-null/info.txt b/test/034-call-null/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/034-call-null/src/Main.java b/test/034-call-null/src/Main.java
new file mode 100644 (file)
index 0000000..a0a129e
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2008 The Android Open Source Project
+
+public class Main {
+    int mFoo = 27;
+
+    private void doStuff() {
+        System.out.println("mFoo is " + mFoo);
+    }
+
+    public static void main(String[] args) {
+        Main instance = null;
+        instance.doStuff();
+    }
+}
diff --git a/test/035-enum/expected.txt b/test/035-enum/expected.txt
new file mode 100644 (file)
index 0000000..50f2791
--- /dev/null
@@ -0,0 +1,3 @@
+found field CRAWLING
+  synthetic? false
+  enum? true
diff --git a/test/035-enum/info.txt b/test/035-enum/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/035-enum/src/Main.java b/test/035-enum/src/Main.java
new file mode 100644 (file)
index 0000000..09fcc98
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2008 The Android Open Source Project
+
+import java.lang.reflect.Field;
+
+/**
+ * Try some stuff with enumerations.
+ */
+public class Main {
+    public enum Shubbery { GROUND, CRAWLING, HANGING }
+
+    public static void main(String[] args) {
+        Field field;
+        try {
+            field = Shubbery.class.getDeclaredField("CRAWLING");
+        } catch (NoSuchFieldException nsfe) {
+            throw new RuntimeException(nsfe);
+        }
+
+        System.out.println("found field " + field.getName());
+        System.out.println("  synthetic? " + field.isSynthetic());
+        System.out.println("  enum? " + field.isEnumConstant());
+    }
+}
diff --git a/test/036-finalizer/expected.txt b/test/036-finalizer/expected.txt
new file mode 100644 (file)
index 0000000..f9b29b0
--- /dev/null
@@ -0,0 +1,14 @@
+wimp: wahoo
+gc
+finalizer executed: wahoo
+wimp: null
+finalize
+wimp: null
+sleep
+reborn: wahoo
+wimp: null
+reset reborn
+gc + finalize
+sleep
+reborn: nothing
+wimp: null
diff --git a/test/036-finalizer/info.txt b/test/036-finalizer/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/036-finalizer/src/FinalizerTest.java b/test/036-finalizer/src/FinalizerTest.java
new file mode 100644 (file)
index 0000000..420ec34
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2008 The Android Open Source Project
+
+import java.lang.ref.WeakReference;
+
+public class FinalizerTest {
+    public static FinalizerTest mNothing = new FinalizerTest("nothing");
+    public static FinalizerTest mReborn = mNothing;
+
+    public String mMsg = "default";
+
+    public FinalizerTest(String msg) {
+        mMsg = msg;
+    }
+
+    public String toString() {
+        return mMsg;
+    }
+
+    protected void finalize() {
+        System.out.println("finalizer executed: " + mMsg);
+        mReborn = this;
+    }
+}
diff --git a/test/036-finalizer/src/Main.java b/test/036-finalizer/src/Main.java
new file mode 100644 (file)
index 0000000..c29cc11
--- /dev/null
@@ -0,0 +1,107 @@
+// Copyright 2008 The Android Open Source Project
+
+import java.lang.ref.WeakReference;
+
+/**
+ * Some finalizer tests.
+ *
+ * This only works if System.runFinalization() causes finalizers to run
+ * immediately or very soon.
+ */
+public class Main {
+    private static void snooze(int ms) {
+        try {
+            Thread.sleep(ms);
+        } catch (InterruptedException ie) {
+            System.out.println("Snooze: " + ie.getMessage());
+        }
+    }
+
+    public static WeakReference makeRef() {
+        /*
+         * Make ft in another thread, so there is no danger of
+         * a conservative reference leaking onto the main thread's
+         * stack.
+         */
+
+        final WeakReference[] wimp = new WeakReference[1];
+        Thread t = new Thread() {
+                public void run() {
+                    FinalizerTest ft = new FinalizerTest("wahoo");
+                    wimp[0] = new WeakReference(ft);
+                    ft = null;
+                }
+            };
+
+        t.start();
+
+        try {
+            t.join();
+        } catch (InterruptedException ie) {
+            throw new RuntimeException(ie);
+        }
+
+        return wimp[0];
+    }
+
+    public static String wimpString(final WeakReference wimp) {
+        /*
+         * Do the work in another thread, so there is no danger of a
+         * conservative reference to ft leaking onto the main thread's
+         * stack.
+         */
+
+        final String[] s = new String[1];
+        Thread t = new Thread() {
+                public void run() {
+                    Object ref = wimp.get();
+                    if (ref != null) {
+                        s[0] = ref.toString();
+                    }
+                }
+            };
+
+        t.start();
+
+        try {
+            t.join();
+        } catch (InterruptedException ie) {
+            throw new RuntimeException(ie);
+        }
+
+        return s[0];
+    }
+
+    public static void main(String[] args) {
+        WeakReference wimp = makeRef();
+
+        System.out.println("wimp: " + wimpString(wimp));
+
+        /* this will try to collect and finalize ft */
+        System.out.println("gc");
+        System.gc();
+
+        System.out.println("wimp: " + wimpString(wimp));
+        System.out.println("finalize");
+        System.runFinalization();
+        System.out.println("wimp: " + wimpString(wimp));
+
+        System.out.println("sleep");
+        snooze(1000);
+
+        System.out.println("reborn: " + FinalizerTest.mReborn);
+        System.out.println("wimp: " + wimpString(wimp));
+        System.out.println("reset reborn");
+        System.gc();
+        FinalizerTest.mReborn = FinalizerTest.mNothing;
+        System.out.println("gc + finalize");
+        System.gc();
+        System.runFinalization();
+
+        System.out.println("sleep");
+        snooze(1000);
+
+        System.out.println("reborn: " + FinalizerTest.mReborn);
+        System.out.println("wimp: " + wimpString(wimp));
+    }
+}
diff --git a/test/037-inherit/expected.txt b/test/037-inherit/expected.txt
new file mode 100644 (file)
index 0000000..1fb9912
--- /dev/null
@@ -0,0 +1,3 @@
+magic is 64.0
+ 0: 64.0
+ 1: 64.0
diff --git a/test/037-inherit/info.txt b/test/037-inherit/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/037-inherit/src/Main.java b/test/037-inherit/src/Main.java
new file mode 100644 (file)
index 0000000..55b782e
--- /dev/null
@@ -0,0 +1,37 @@
+public class Main {
+    static void arrayCluster(IMagic[] magicArray) {
+        int i;
+
+        for (i = 0; i < magicArray.length; i++)
+            System.out.println(" " + i + ": " + magicArray[i].getSomeData());
+    }
+
+    public static void main(String args[]) {
+        MagicClass magic = new MagicClass();
+
+        System.out.print("magic is ");
+        System.out.println(magic.getSomeData());
+
+        MagicClass magicArray[] = new MagicClass[2];
+        magicArray[0] = new MagicClass();
+        magicArray[1] = new MagicClass();
+        arrayCluster(magicArray);
+    }
+}
+
+class IntSource {
+    public int getMagicInt() { return 64; }
+}
+
+interface IMagic {
+    public double getSomeData();
+
+    IntSource mIntSource = new IntSource();
+    public int MAGIC_INT = mIntSource.getMagicInt();
+}
+
+class MagicClass implements IMagic {
+    public double getSomeData() {
+        return this.MAGIC_INT;
+    }
+}
diff --git a/test/038-inner-null/expected.txt b/test/038-inner-null/expected.txt
new file mode 100644 (file)
index 0000000..0be8ffd
--- /dev/null
@@ -0,0 +1,5 @@
+new Special()
+java.lang.NullPointerException
+       at Main$Special.callInner(Main.java:17)
+       at Main.main(Main.java:6)
+       at dalvik.system.NativeStart.main(Native Method)
diff --git a/test/038-inner-null/info.txt b/test/038-inner-null/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/038-inner-null/src/Main.java b/test/038-inner-null/src/Main.java
new file mode 100644 (file)
index 0000000..acc8764
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright 2008 The Android Open Source Project
+
+public class Main {
+    public static void main(String[] args) {
+        Special special = new Special();
+        special.callInner();
+    }
+
+    public static class Special {
+        Blort mBlort = null;
+
+        Special() {
+            System.out.println("new Special()");
+        }
+
+        public void callInner() {
+            mBlort.repaint();
+        }
+    }
+
+    private class Blort {
+        public void repaint() {
+            System.out.println("shouldn't see this");
+        }
+    }
+
+}
diff --git a/test/039-join-main/expected.txt b/test/039-join-main/expected.txt
new file mode 100644 (file)
index 0000000..37e6d77
--- /dev/null
@@ -0,0 +1,5 @@
+Starting thread 'Joiner'
+@ JoinMainSub running
+JoinMain starter returning
+@ JoinMainSub successfully joined main
+@ JoinMainSub bailing
diff --git a/test/039-join-main/info.txt b/test/039-join-main/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/039-join-main/src/Main.java b/test/039-join-main/src/Main.java
new file mode 100644 (file)
index 0000000..0644f1c
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright 2007 The Android Open Source Project
+
+/**
+ * Make sure that a sub-thread can join the main thread.
+ */
+public class Main {
+    public static void main(String[] args) {
+        Thread t;
+
+        t = new Thread(new JoinMainSub(Thread.currentThread()), "Joiner");
+        System.out.print("Starting thread '" + t.getName() + "'\n");
+        t.start();
+
+        try { Thread.sleep(1000); }
+        catch (InterruptedException ie) {}
+
+        System.out.print("JoinMain starter returning\n");
+    }
+}
+
+class JoinMainSub implements Runnable {
+    private Thread mJoinMe;
+
+    public JoinMainSub(Thread joinMe) {
+        mJoinMe = joinMe;
+    }
+
+    public void run() {
+        System.out.print("@ JoinMainSub running\n");
+
+        try {
+            mJoinMe.join();
+            System.out.print("@ JoinMainSub successfully joined main\n");
+        } catch (InterruptedException ie) {
+            System.out.print("@ JoinMainSub interrupted!\n");
+        }
+        finally {
+            System.out.print("@ JoinMainSub bailing\n");
+        }
+    }
+}
diff --git a/test/040-miranda/expected.txt b/test/040-miranda/expected.txt
new file mode 100644 (file)
index 0000000..e22bbd9
--- /dev/null
@@ -0,0 +1,12 @@
+MirandaClass:
+  inInterface:  true
+  inInterface2: 27
+  inAbstract:   false
+MirandaAbstract / MirandaClass:
+  inInterface:  true
+  inInterface2: 27
+  inAbstract:   false
+MirandaAbstract / MirandaClass2:
+  inInterface:  true
+  inInterface2: 28
+  inAbstract:   true
diff --git a/test/040-miranda/info.txt b/test/040-miranda/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/040-miranda/src/Main.java b/test/040-miranda/src/Main.java
new file mode 100644 (file)
index 0000000..558806a
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Miranda testing.
+ */
+public class Main {
+    public static void main(String[] args) {
+        MirandaClass mir = new MirandaClass();
+        System.out.println("MirandaClass:");
+        System.out.println("  inInterface:  " + mir.inInterface());
+        System.out.println("  inInterface2: " + mir.inInterface2());
+        System.out.println("  inAbstract:   " + mir.inAbstract());
+
+        /* try again through abstract class; results should be identical */
+        MirandaAbstract mira = mir;
+        System.out.println("MirandaAbstract / MirandaClass:");
+        System.out.println("  inInterface:  " + mira.inInterface());
+        System.out.println("  inInterface2: " + mira.inInterface2());
+        System.out.println("  inAbstract:   " + mira.inAbstract());
+
+        MirandaAbstract mira2 = new MirandaClass2();
+        System.out.println("MirandaAbstract / MirandaClass2:");
+        System.out.println("  inInterface:  " + mira2.inInterface());
+        System.out.println("  inInterface2: " + mira2.inInterface2());
+        System.out.println("  inAbstract:   " + mira2.inAbstract());
+    }
+}
diff --git a/test/040-miranda/src/MirandaAbstract.java b/test/040-miranda/src/MirandaAbstract.java
new file mode 100644 (file)
index 0000000..b603ce6
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Miranda testing.
+ */
+public abstract class MirandaAbstract implements MirandaInterface, MirandaInterface2
+{
+    protected MirandaAbstract() { }
+
+    //public abstract boolean inInterface();
+    //public abstract int inInterface2();
+
+    public boolean inAbstract() {
+        return true;
+    }
+}
diff --git a/test/040-miranda/src/MirandaClass.java b/test/040-miranda/src/MirandaClass.java
new file mode 100644 (file)
index 0000000..3bf6704
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Miranda testing.
+ */
+public class MirandaClass extends MirandaAbstract {
+
+    public MirandaClass() {}
+
+    public boolean inInterface() {
+        //System.out.println("    MirandaClass inInterface");
+        return true;
+    }
+
+    public int inInterface2() {
+        //System.out.println("    MirandaClass inInterface2");
+        return 27;
+    }
+
+    public boolean inAbstract() {
+        //System.out.println("    MirandaClass inAbstract");
+        return false;
+    }
+}
diff --git a/test/040-miranda/src/MirandaClass2.java b/test/040-miranda/src/MirandaClass2.java
new file mode 100644 (file)
index 0000000..e9bdf2b
--- /dev/null
@@ -0,0 +1,9 @@
+class MirandaClass2 extends MirandaAbstract {
+    public boolean inInterface() {
+        return true;
+    }
+
+    public int inInterface2() {
+        return 28;
+    }
+}
diff --git a/test/040-miranda/src/MirandaInterface.java b/test/040-miranda/src/MirandaInterface.java
new file mode 100644 (file)
index 0000000..2c0a59a
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Miranda testing.
+ */
+public interface MirandaInterface {
+
+    public boolean inInterface();
+
+}
diff --git a/test/040-miranda/src/MirandaInterface2.java b/test/040-miranda/src/MirandaInterface2.java
new file mode 100644 (file)
index 0000000..83b6af8
--- /dev/null
@@ -0,0 +1,12 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Miranda testing.
+ */
+public interface MirandaInterface2 {
+
+    public boolean inInterface();
+
+    public int inInterface2();
+
+}
diff --git a/test/041-narrowing/expected.txt b/test/041-narrowing/expected.txt
new file mode 100644 (file)
index 0000000..93b8590
--- /dev/null
@@ -0,0 +1,38 @@
+
+Double.POSITIVE_INFINITY = 7ff0000000000000
+Double.NEGATIVE_INFINITY = fff0000000000000
+Float.POSITIVE_INFINITY  = 7ff0000000000000
+Float.NEGATIVE_INFINITY  = fff0000000000000
+Double.NaN               = 7ff8000000000000
+Float.NaN                = 7ff8000000000000
+
+(byte) Double.NaN  =               00 expected:               00
+(short) Double.NaN =             0000 expected:             0000
+(int) Double.NaN   =         00000000 expected:         00000000
+(long) Double.NaN  = 0000000000000000 expected: 0000000000000000
+
+(byte) Float.NaN  =               00 expected:               00
+(short) Float.NaN =             0000 expected:             0000
+(int) Float.NaN   =         00000000 expected:         00000000
+(long) Float.NaN  = 0000000000000000 expected: 0000000000000000
+
+(byte) Double.POSITIVE_INFINITY  =               ff expected:               ff
+(short) Double.POSITIVE_INFINITY =             ffff expected:             ffff
+(int) Double.POSITIVE_INFINITY   =         7fffffff expected:         7fffffff
+(long) Double.POSITIVE_INFINITY  = 7fffffffffffffff expected: 7fffffffffffffff
+
+(byte) Double.NEGATIVE_INFINITY  =               00 expected:               00
+(short) Double.NEGATIVE_INFINITY =             0000 expected:             0000
+(int) Double.NEGATIVE_INFINITY   =         80000000 expected:         80000000
+(long) Double.NEGATIVE_INFINITY  = 8000000000000000 expected: 8000000000000000
+
+(byte) Float.POSITIVE_INFINITY   =               ff expected:               ff
+(short) Float.POSITIVE_INFINITY  =             ffff expected:             ffff
+(int) Float.POSITIVE_INFINITY    =         7fffffff expected:         7fffffff
+(long) Float.POSITIVE_INFINITY   = 7fffffffffffffff expected: 7fffffffffffffff
+
+(byte) Float.NEGATIVE_INFINITY   =               00 expected:               00
+(short) Float.NEGATIVE_INFINITY  =             0000 expected:             0000
+(int) Float.NEGATIVE_INFINITY    =         80000000 expected:         80000000
+(long) Float.NEGATIVE_INFINITY   = 8000000000000000 expected: 8000000000000000
+
diff --git a/test/041-narrowing/info.txt b/test/041-narrowing/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/041-narrowing/src/Main.java b/test/041-narrowing/src/Main.java
new file mode 100644 (file)
index 0000000..eb9d64a
--- /dev/null
@@ -0,0 +1,99 @@
+public class Main {
+    public static void main(String[] args) {
+        test_printNarrowing();
+    }
+
+    public static void test_printNarrowing() {
+
+        System.out.println();
+        System.out.println("Double.POSITIVE_INFINITY = "
+                + Long.toHexString(Double.doubleToRawLongBits(Double.POSITIVE_INFINITY)));
+        System.out.println("Double.NEGATIVE_INFINITY = "
+                + Long.toHexString(Double.doubleToRawLongBits(Double.NEGATIVE_INFINITY)));
+        System.out.println("Float.POSITIVE_INFINITY  = "
+                + Long.toHexString(Double.doubleToRawLongBits(Float.POSITIVE_INFINITY)));
+        System.out.println("Float.NEGATIVE_INFINITY  = "
+                + Long.toHexString(Double.doubleToRawLongBits(Float.NEGATIVE_INFINITY)));
+        System.out.println("Double.NaN               = "
+                + Long.toHexString(Double.doubleToRawLongBits(Double.NaN)));
+        System.out.println("Float.NaN                = "
+                + Long.toHexString(Double.doubleToRawLongBits(Float.NaN)));
+        double dbl2 = Double.NaN;
+        System.out.println();
+        System.out.println("(byte) Double.NaN  =               "
+                + (Long.toHexString((byte)dbl2).equals("0") ? "00" : Long.toHexString((byte)dbl2)
+                        .substring(6)) + " expected:               00");
+        System.out.println("(short) Double.NaN =             "
+                + (Integer.toHexString((short)dbl2).equals("0") ? "0000" : Integer.toHexString(
+                        (short)dbl2).substring(4)) + " expected:             0000");
+        System.out.println("(int) Double.NaN   =         "
+                + (Integer.toHexString((int)dbl2).equals("0") ? "00000000" : Integer
+                        .toHexString((int)dbl2)) + " expected:         00000000");
+        System.out.println("(long) Double.NaN  = "
+                + (Long.toHexString((long)dbl2).equals("0") ? "0000000000000000" : Long
+                        .toHexString((long)dbl2)) + " expected: 0000000000000000");
+        float fl2 = Float.NaN;
+        System.out.println();
+        System.out.println("(byte) Float.NaN  =               "
+                + (Long.toHexString((byte)fl2).equals("0") ? "00" : Long.toHexString((byte)fl2)
+                        .substring(6)) + " expected:               00");
+        System.out.println("(short) Float.NaN =             "
+                + (Integer.toHexString((short)fl2).equals("0") ? "0000" : Integer.toHexString(
+                        (short)fl2).substring(4)) + " expected:             0000");
+        System.out.println("(int) Float.NaN   =         "
+                + (Integer.toHexString((int)fl2).equals("0") ? "00000000" : Integer
+                        .toHexString((int)fl2)) + " expected:         00000000");
+        System.out.println("(long) Float.NaN  = "
+                + (Long.toHexString((long)fl2).equals("0") ? "0000000000000000" : Long
+                        .toHexString((long)fl2)) + " expected: 0000000000000000");
+        double dbl3 = Double.POSITIVE_INFINITY;
+        System.out.println();
+        System.out.println("(byte) Double.POSITIVE_INFINITY  =               "
+                + (Integer.toHexString((byte)dbl3).equals("0") ? "00" : Integer.toHexString(
+                        (byte)dbl3).substring(6)) + " expected:               ff");
+        System.out.println("(short) Double.POSITIVE_INFINITY =             "
+                + (Integer.toHexString((short)dbl3).equals("0") ? "0000" : Integer.toHexString(
+                        (short)dbl3).substring(4)) + " expected:             ffff");
+        System.out.println("(int) Double.POSITIVE_INFINITY   =         "
+                + Integer.toHexString((int)dbl3) + " expected:         7fffffff");
+        System.out.println("(long) Double.POSITIVE_INFINITY  = " + Long.toHexString((long)dbl3)
+                + " expected: 7fffffffffffffff");
+        double dbl4 = Double.NEGATIVE_INFINITY;
+        System.out.println();
+        System.out.println("(byte) Double.NEGATIVE_INFINITY  = "
+                + (Long.toHexString((byte)dbl4).equals("0") ? "              00" : Long
+                        .toHexString((byte)dbl4)) + " expected:               00");
+        System.out.println("(short) Double.NEGATIVE_INFINITY = "
+                + (Integer.toHexString((short)dbl4).equals("0") ? "            0000" : Long
+                        .toHexString((short)dbl4)) + " expected:             0000");
+        System.out.println("(int) Double.NEGATIVE_INFINITY   =         "
+                + Integer.toHexString((int)dbl4) + " expected:         80000000");
+        System.out.println("(long) Double.NEGATIVE_INFINITY  = " + Long.toHexString((long)dbl4)
+                + " expected: 8000000000000000");
+        float fl3 = Float.POSITIVE_INFINITY;
+        System.out.println();
+        System.out.println("(byte) Float.POSITIVE_INFINITY   =               "
+                + (Integer.toHexString((byte)fl3).equals("0") ? "00" : Integer.toHexString(
+                        (byte)fl3).substring(6)) + " expected:               ff");
+        System.out.println("(short) Float.POSITIVE_INFINITY  =             "
+                + (Integer.toHexString((short)fl3).equals("0") ? "0000" : Integer.toHexString(
+                        (short)fl3).substring(4)) + " expected:             ffff");
+        System.out.println("(int) Float.POSITIVE_INFINITY    =         "
+                + Integer.toHexString((int)fl3) + " expected:         7fffffff");
+        System.out.println("(long) Float.POSITIVE_INFINITY   = " + Long.toHexString((long)fl3)
+                + " expected: 7fffffffffffffff");
+        float fl4 = Float.NEGATIVE_INFINITY;
+        System.out.println();
+        System.out.println("(byte) Float.NEGATIVE_INFINITY   = "
+                + (Long.toHexString((byte)fl4).equals("0") ? "              00" : Long
+                        .toHexString((byte)fl4)) + " expected:               00");
+        System.out.println("(short) Float.NEGATIVE_INFINITY  = "
+                + (Integer.toHexString((short)fl4).equals("0") ? "            0000" : Long
+                        .toHexString((short)fl4)) + " expected:             0000");
+        System.out.println("(int) Float.NEGATIVE_INFINITY    =         "
+                + Integer.toHexString((int)fl4) + " expected:         80000000");
+        System.out.println("(long) Float.NEGATIVE_INFINITY   = " + Long.toHexString((long)fl4)
+                + " expected: 8000000000000000");
+        System.out.println();
+    }
+}
diff --git a/test/042-new-instance/expected.txt b/test/042-new-instance/expected.txt
new file mode 100644 (file)
index 0000000..53447db
--- /dev/null
@@ -0,0 +1,8 @@
+LocalClass succeeded
+Got expected PackageAccess complaint
+LocalClass3 succeeded
+Got expected InstantationError
+Cons LocalClass failed as expected
+Cons LocalClass2 succeeded
+Cons got expected PackageAccess complaint
+Cons got expected InstantationException
diff --git a/test/042-new-instance/info.txt b/test/042-new-instance/info.txt
new file mode 100644 (file)
index 0000000..49c9e02
--- /dev/null
@@ -0,0 +1,2 @@
+Test various permutations of Class.newInstance and Constructor.newInstance,
+looking for correct handling of access rights and abstract classes.
diff --git a/test/042-new-instance/src/Main.java b/test/042-new-instance/src/Main.java
new file mode 100644 (file)
index 0000000..8faef13
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.reflect.Constructor;
+
+import java.lang.reflect.Constructor;
+
+/**
+ * Test instance creation.
+ */
+public class Main {
+    public static void main(String[] args) {
+        testClassNewInstance();
+        testConstructorNewInstance();
+    }
+
+    /**
+     * Tests Class.newInstance().
+     */
+    static void testClassNewInstance() {
+        // should succeed
+        try {
+            Class c = Class.forName("LocalClass");
+            Object obj = c.newInstance();
+            System.out.println("LocalClass succeeded");
+        } catch (Exception ex) {
+            System.err.println("LocalClass failed");
+            ex.printStackTrace();
+        }
+
+        // should fail
+        try {
+            Class c = Class.forName("otherpackage.PackageAccess");
+            Object obj = c.newInstance();
+            System.err.println("ERROR: PackageAccess succeeded unexpectedly");
+        } catch (IllegalAccessException iae) {
+            System.out.println("Got expected PackageAccess complaint");
+        } catch (Exception ex) {
+            System.err.println("Got unexpected PackageAccess failure");
+            ex.printStackTrace();
+        }
+
+        LocalClass3.main();
+
+        try {
+            MaybeAbstract ma = new MaybeAbstract();
+            System.err.println("ERROR: MaybeAbstract succeeded unexpectedly");
+        } catch (InstantiationError ie) {
+            System.out.println("Got expected InstantationError");
+        } catch (Exception ex) {
+            System.err.println("Got unexpected MaybeAbstract failure");
+        }
+    }
+
+    /**
+     * Tests Constructor.newInstance().
+     */
+    static void testConstructorNewInstance() {
+        // should fail -- getConstructor only returns public constructors
+        try {
+            Class c = Class.forName("LocalClass");
+            Constructor cons = c.getConstructor(new Class[0] /*(Class[])null*/);
+            System.err.println("Cons LocalClass succeeded unexpectedly");
+        } catch (NoSuchMethodException nsme) {
+            System.out.println("Cons LocalClass failed as expected");
+        } catch (Exception ex) {
+            System.err.println("Cons LocalClass failed strangely");
+            ex.printStackTrace();
+        }
+
+        // should succeed
+        try {
+            Class c = Class.forName("LocalClass2");
+            Constructor cons = c.getConstructor((Class[]) null);
+            Object obj = cons.newInstance();
+            System.out.println("Cons LocalClass2 succeeded");
+        } catch (Exception ex) {
+            System.err.println("Cons LocalClass2 failed");
+            ex.printStackTrace();
+        }
+
+        // should fail
+        try {
+            Class c = Class.forName("otherpackage.PackageAccess");
+            Constructor cons = c.getConstructor(new Class[0] /*(Class[])null*/);
+            System.err.println("ERROR: Cons PackageAccess succeeded unexpectedly");
+        } catch (NoSuchMethodException nsme) {
+            System.out.println("Cons got expected PackageAccess complaint");
+        } catch (Exception ex) {
+            System.err.println("Cons got unexpected PackageAccess failure");
+            ex.printStackTrace();
+        }
+
+        // should fail
+        try {
+            Class c = Class.forName("MaybeAbstract");
+            Constructor cons = c.getConstructor(new Class[0] /*(Class[])null*/);
+            Object obj = cons.newInstance();
+            System.err.println("ERROR: Cons MaybeAbstract succeeded unexpectedly");
+        } catch (InstantiationException ie) {
+            // note InstantiationException vs. InstantiationError
+            System.out.println("Cons got expected InstantationException");
+        } catch (Exception ex) {
+            System.err.println("Cons got unexpected MaybeAbstract failure");
+            ex.printStackTrace();
+        }
+    }
+}
+
+class LocalClass {
+    // this class has a default constructor with package visibility
+}
+
+class LocalClass2 {
+    public LocalClass2() {}
+}
+
+
+class LocalClass3 {
+    public static void main() {
+        try {
+            CC.newInstance();
+            System.out.println("LocalClass3 succeeded");
+        } catch (Exception ex) {
+            System.err.println("Got unexpected LocalClass3 failure");
+            ex.printStackTrace();
+        }
+    }
+
+    static class CC {
+        private CC() {}
+
+        static Object newInstance() {
+            try {
+                Class c = CC.class;
+                return c.newInstance();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                return null;
+            }
+        }
+    }
+}
diff --git a/test/042-new-instance/src/MaybeAbstract.java b/test/042-new-instance/src/MaybeAbstract.java
new file mode 100644 (file)
index 0000000..6d3b05b
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public /*abstract*/ class MaybeAbstract {
+    public MaybeAbstract() {}
+    int foo() { return 0; }
+}
diff --git a/test/042-new-instance/src/otherpackage/PackageAccess.java b/test/042-new-instance/src/otherpackage/PackageAccess.java
new file mode 100644 (file)
index 0000000..0749d67
--- /dev/null
@@ -0,0 +1,6 @@
+package otherpackage;
+
+class PackageAccess {
+    /*package*/ PackageAccess() {
+    }
+}
diff --git a/test/042-new-instance/src2/MaybeAbstract.java b/test/042-new-instance/src2/MaybeAbstract.java
new file mode 100644 (file)
index 0000000..8b70a07
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public abstract class MaybeAbstract {
+    public MaybeAbstract() {}
+    int foo() { return 0; }
+}
diff --git a/test/043-privates/expected.txt b/test/043-privates/expected.txt
new file mode 100644 (file)
index 0000000..2779ec7
--- /dev/null
@@ -0,0 +1,6 @@
+PrivatePackage --> PrivatePackage!
+PrivatePackage --> PrivatePackage!
+PrivatePackage --> PrivatePackage!
+PrivatePackageSub --> PrivatePackageSub!
+PrivatePackage --> PrivatePackage!
+PrivatePackage --> PrivatePackage!
diff --git a/test/043-privates/info.txt b/test/043-privates/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/043-privates/src/Main.java b/test/043-privates/src/Main.java
new file mode 100644 (file)
index 0000000..73b4d79
--- /dev/null
@@ -0,0 +1,45 @@
+// Copyright 2007 The Android Open Source Project
+
+/**
+ * Make sure private methods don't inherit.
+ */
+public class Main {
+    public static void main(String args[]) {
+        PrivatePackage inst1 = new PrivatePackage();
+        PrivatePackage inst2 = new PrivatePackageSub();
+        PrivatePackageSub inst3 = new PrivatePackageSub();
+
+        System.out.println("PrivatePackage --> " + inst1.getStr());
+        System.out.println("PrivatePackage --> " + inst2.getStr());
+        System.out.println("PrivatePackage --> " + inst3.getStr());
+        System.out.println("PrivatePackageSub --> " + inst3.getStrSub());
+
+        inst1.stretchTest();
+    }
+}
+
+class PrivatePackage {
+    public String getStr() {
+        return privGetStr();
+    }
+
+    private String privGetStr() {
+        return "PrivatePackage!";
+    }
+
+    public void stretchTest() {
+        PrivatePackage inst = new PrivatePackageSub();
+        System.out.println("PrivatePackage --> " + inst.getStr());
+        System.out.println("PrivatePackage --> " + inst.privGetStr());
+    }
+}
+
+class PrivatePackageSub extends PrivatePackage {
+    public String getStrSub() {
+        return privGetStr();
+    }
+
+    private String privGetStr() {
+        return "PrivatePackageSub!";
+    }
+}
diff --git a/test/044-proxy/expected.txt b/test/044-proxy/expected.txt
new file mode 100644 (file)
index 0000000..4be26cf
--- /dev/null
@@ -0,0 +1,80 @@
+Invoke public abstract void Shapes.circle(int)
+ 0: 3
+--- circle 3
+Success: method circle res=null
+Invoke public abstract int Quads.rectangle(int,int)
+ 0: 10
+ 1: 20
+--- rectangle 10,20
+Success: method rectangle res=4
+Invoke public abstract java.lang.String Shapes.blob()
+ (no args)
+--- blob
+Success: method blob res=mix
+Invoke public abstract int Quads.rectangle(int,int)
+ 0: 15
+ 1: 25
+--- rectangle 15,25
+Success: method rectangle res=4
+Invoke public abstract int Quads.trapezoid(int,double,int)
+ 0: 6
+ 1: 81.18
+ 2: 4
+--- trap 6,4,81.18
+Success: method trapezoid res=8
+Invoke public abstract int Colors.red(float)
+ 0: 1.0
+--- red 1.0
+Success: method red res=0
+Invoke public abstract double Colors.blue(int)
+ 0: 777
+--- blue 777
+Success: method blue res=2.54
+Invoke public abstract int Colors.mauve(java.lang.String)
+ 0: sorry
+--- mauve sorry
+Success: method mauve res=3
+Invoke public abstract java.lang.String Shapes.blob()
+ (no args)
+--- blob
+Success: method blob res=mix
+Invoke public abstract void Shapes.upChuck()
+ (no args)
+Got expected ioobe
+Invoke public abstract void Shapes.upCheck() throws java.lang.InterruptedException
+ (no args)
+Got expected ie
+
+Proxy methods: [public native boolean $Proxy0.equals(java.lang.Object), public native int $Proxy0.hashCode(), public native java.lang.String $Proxy0.toString(), public native int $Proxy0.rectangle(int,int), public native int $Proxy0.square(int,int), public native int $Proxy0.trapezoid(int,double,int), public native java.lang.String $Proxy0.blob(), public native void $Proxy0.circle(int), public native void $Proxy0.upCheck(), public native void $Proxy0.upChuck(), public native double $Proxy0.blue(int), public native R0aa $Proxy0.checkMe(), public native int $Proxy0.green(double), public native int $Proxy0.mauve(java.lang.String), public native int $Proxy0.red(float)]
+Decl annos: []
+Param annos (1) : [[]]
+Proxy fields: [private static java.lang.Throwable[][] $Proxy0.throws]
+Dupe threw expected exception
+Clash threw expected exception
+Clash2 threw expected exception
+Clash3 threw expected exception
+Clash4 threw expected exception
+Invoke public abstract void InterfaceW1.throwFunky()
+ (no args)
+Got expected UTE
+Invoke public abstract void InterfaceW1.throwFunky2() throws BaseException,java.lang.NoSuchMethodException,java.io.IOException
+ (no args)
+Got expected IOE
+Invoke public abstract void InterfaceW1.throwFunky2() throws BaseException,java.lang.NoSuchMethodException,java.io.IOException
+ (no args)
+Got expected IOE
+Invoke public abstract void InterfaceW1.throwException() throws BaseException
+ (no args)
+Got expected UTE
+Invoke public abstract void InterfaceW1.throwBase() throws BaseException
+ (no args)
+Got expected UTE
+Invoke public abstract void InterfaceW1.throwSub() throws BaseException
+ (no args)
+Got expected exception
+Invoke public abstract void InterfaceW1.throwSubSub() throws BaseException
+ (no args)
+Got expected exception
+Invoke public abstract void InterfaceW1.bothThrowBase() throws BaseException,SubException,SubSubException
+ (no args)
+Got expected exception
diff --git a/test/044-proxy/info.txt b/test/044-proxy/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/044-proxy/src/BasicTest.java b/test/044-proxy/src/BasicTest.java
new file mode 100644 (file)
index 0000000..2a453c4
--- /dev/null
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Arrays;
+
+/**
+ * Do some basic tests.
+ */
+public class BasicTest {
+
+    public static void main(String[] args) {
+        Mix proxyMe = new Mix();
+        Object proxy = createProxy(proxyMe);
+
+        if (!Proxy.isProxyClass(proxy.getClass()))
+            System.err.println("not a proxy class?");
+        if (Proxy.getInvocationHandler(proxy) == null)
+            System.err.println("ERROR: Proxy.getInvocationHandler is null");
+
+        /* take it for a spin; verifies instanceof constraint */
+        Shapes shapes = (Shapes) proxy;
+        shapes.circle(3);
+        shapes.rectangle(10, 20);
+        shapes.blob();
+        Quads quads = (Quads) proxy;
+        quads.rectangle(15, 25);
+        quads.trapezoid(6, 81.18, 4);
+        Colors colors = (Colors) proxy;
+        colors.red(1.0f);
+        colors.blue(777);
+        colors.mauve("sorry");
+        colors.blob();
+
+        try {
+            shapes.upChuck();
+            System.out.println("Didn't get expected exception");
+        } catch (IndexOutOfBoundsException ioobe) {
+            System.out.println("Got expected ioobe");
+        }
+        try {
+            shapes.upCheck();
+            System.out.println("Didn't get expected exception");
+        } catch (InterruptedException ie) {
+            System.out.println("Got expected ie");
+        }
+
+        /*
+         * Exercise annotations on Proxy classes.  This is mostly to ensure
+         * that annotation calls work correctly on generated classes.
+         */
+        System.out.println("");
+        Method[] methods = proxy.getClass().getDeclaredMethods();
+        System.out.println("Proxy methods: " + Arrays.deepToString(methods));
+        Method meth = methods[methods.length -1];
+        System.out.println("Decl annos: " + Arrays.deepToString(meth.getDeclaredAnnotations()));
+        Annotation[][] paramAnnos = meth.getParameterAnnotations();
+        System.out.println("Param annos (" + paramAnnos.length + ") : "
+            + Arrays.deepToString(paramAnnos));
+        Field[] fields = proxy.getClass().getDeclaredFields();
+        System.out.println("Proxy fields: " + Arrays.deepToString(fields));
+    }
+
+    static Object createProxy(Object proxyMe) {
+        /* declare an object that will handle the method calls */
+        InvocationHandler handler = new MyInvocationHandler(proxyMe);
+
+        /* create the proxy class */
+        Class proxyClass = Proxy.getProxyClass(Shapes.class.getClassLoader(),
+                            new Class[] { Quads.class, Colors.class });
+
+        /* create a proxy object, passing the handler object in */
+        Object proxy = null;
+        try {
+            Constructor<Class> cons;
+            cons = proxyClass.getConstructor(
+                            new Class[] { InvocationHandler.class });
+            //System.out.println("Constructor is " + cons);
+            proxy = cons.newInstance(new Object[] { handler });
+        } catch (NoSuchMethodException nsme) {
+            System.err.println("failed: " + nsme);
+        } catch (InstantiationException ie) {
+            System.err.println("failed: " + ie);
+        } catch (IllegalAccessException ie) {
+            System.err.println("failed: " + ie);
+        } catch (InvocationTargetException ite) {
+            System.err.println("failed: " + ite);
+        }
+
+        return proxy;
+    }
+}
+
+/*
+ * Some interfaces.
+ */
+interface Shapes {
+    public void circle(int r);
+    public int rectangle(int x, int y);
+
+    public String blob();
+
+    public R0base checkMe();
+    public void upChuck();
+    public void upCheck() throws InterruptedException;
+}
+
+interface Quads extends Shapes {
+    public int rectangle(int x, int y);
+    public int square(int x, int y);
+    public int trapezoid(int x, double off, int y);
+
+    public R0a checkMe();
+}
+
+/*
+ * More interfaces.
+ */
+interface Colors {
+    public int red(float howRed);
+    public int green(double howGreen);
+    public double blue(int howBlue);
+    public int mauve(String apology);
+
+    public String blob();
+
+    public R0aa checkMe();
+}
+
+/*
+ * Some return types.
+ */
+class R0base { int mBlah;  }
+class R0a extends R0base { int mBlah_a;  }
+class R0aa extends R0a { int mBlah_aa;  }
+
+
+/*
+ * A class that implements them all.
+ */
+class Mix implements Quads, Colors {
+    public void circle(int r) {
+        System.out.println("--- circle " + r);
+    }
+    public int rectangle(int x, int y) {
+        System.out.println("--- rectangle " + x + "," + y);
+        return 4;
+    }
+    public int square(int x, int y) {
+        System.out.println("--- square " + x + "," + y);
+        return 4;
+    }
+    public int trapezoid(int x, double off, int y) {
+        System.out.println("--- trap " + x + "," + y + "," + off);
+        return 8;
+    }
+    public String blob() {
+        System.out.println("--- blob");
+        return "mix";
+    }
+
+    public int red(float howRed) {
+        System.out.println("--- red " + howRed);
+        return 0;
+    }
+    public int green(double howGreen) {
+        System.out.println("--- green " + howGreen);
+        return 1;
+    }
+    public double blue(int howBlue) {
+        System.out.println("--- blue " + howBlue);
+        return 2.54;
+    }
+    public int mauve(String apology) {
+        System.out.println("--- mauve " + apology);
+        return 3;
+    }
+
+    public R0aa checkMe() {
+        return null;
+    }
+    public void upChuck() {
+        throw new IndexOutOfBoundsException("upchuck");
+    }
+    public void upCheck() throws InterruptedException {
+        throw new InterruptedException("upcheck");
+    }
+}
+
+/*
+ * Invocation handler, defining the implementation of the proxy functions.
+ */
+class MyInvocationHandler implements InvocationHandler {
+    Object mObj;
+
+    public MyInvocationHandler(Object obj) {
+        mObj = obj;
+    }
+
+    /*
+     * This is called when anything gets invoked in the proxy object.
+     */
+    public Object invoke(Object proxy, Method method, Object[] args)
+        throws Throwable {
+
+        Object result = null;
+
+        // Trap Object calls.  This is important here to avoid a recursive
+        // invocation of toString() in the print statements below.
+        if (method.getDeclaringClass() == java.lang.Object.class) {
+            //System.out.println("!!! object " + method.getName());
+            if (method.getName().equals("toString"))
+                return super.toString();
+            else if (method.getName().equals("hashCode"))
+                return Integer.valueOf(super.hashCode());
+            else if (method.getName().equals("equals"))
+                return Boolean.valueOf(super.equals(args[0]));
+            else
+                throw new RuntimeException("huh?");
+        }
+
+        System.out.println("Invoke " + method);
+        if (args == null || args.length == 0) {
+            System.out.println(" (no args)");
+        } else {
+            for (int i = 0; i < args.length; i++)
+                System.out.println(" " + i + ": " + args[i]);
+        }
+
+        try {
+            if (true)
+                result = method.invoke(mObj, args);
+            else
+                result = -1;
+            System.out.println("Success: method " + method.getName()
+                + " res=" + result);
+        } catch (InvocationTargetException ite) {
+            throw ite.getTargetException();
+        } catch (IllegalAccessException iae) {
+            throw new RuntimeException(iae);
+        }
+        return result;
+    }
+}
diff --git a/test/044-proxy/src/Clash.java b/test/044-proxy/src/Clash.java
new file mode 100644 (file)
index 0000000..adeffdc
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+/*
+ * Try to instantiate a proxy class with interfaces that have conflicting
+ * duplicate methods (primitive vs. object).
+ */
+public class Clash {
+    public static void main(String[] args) {
+        InvocationHandler handler = new ClashInvocationHandler();
+
+        /* try passing in the same interface twice */
+        try {
+            Proxy.newProxyInstance(Clash.class.getClassLoader(),
+                new Class[] { Interface1A.class, Interface1A.class },
+                handler);
+            System.err.println("Dupe did not throw expected exception");
+        } catch (IllegalArgumentException iae) {
+            System.out.println("Dupe threw expected exception");
+        }
+
+        try {
+            Proxy.newProxyInstance(Clash.class.getClassLoader(),
+                new Class[] { Interface1A.class, Interface1B.class },
+                handler);
+            System.err.println("Clash did not throw expected exception");
+        } catch (IllegalArgumentException iae) {
+            System.out.println("Clash threw expected exception");
+        }
+    }
+}
+
+interface Interface1A {
+    public int thisIsOkay();
+
+    public float thisIsTrouble();
+}
+
+interface Interface1B {
+    public int thisIsOkay();
+
+    public Object thisIsTrouble();
+}
+
+class ClashInvocationHandler implements InvocationHandler {
+    /* don't really need to do anything -- should never get this far */
+    public Object invoke(Object proxy, Method method, Object[] args)
+        throws Throwable {
+
+        return null;
+    }
+}
diff --git a/test/044-proxy/src/Clash2.java b/test/044-proxy/src/Clash2.java
new file mode 100644 (file)
index 0000000..2a384f4
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+/*
+ * Try to instantiate a proxy class with interfaces that have conflicting
+ * duplicate methods (primitive types).
+ */
+public class Clash2 {
+    public static void main(String[] args) {
+        InvocationHandler handler = new Clash2InvocationHandler();
+
+        try {
+            Proxy.newProxyInstance(Clash.class.getClassLoader(),
+                new Class[] { Interface2A.class, Interface2B.class },
+                handler);
+            System.err.println("Clash2 did not throw expected exception");
+        } catch (IllegalArgumentException iae) {
+            System.out.println("Clash2 threw expected exception");
+        }
+    }
+}
+
+interface Interface2A {
+    public int thisIsOkay();
+
+    public int thisIsTrouble();
+}
+
+interface Interface2B {
+    public int thisIsOkay();
+
+    public short thisIsTrouble();
+}
+
+class Clash2InvocationHandler implements InvocationHandler {
+    /* don't really need to do anything -- should never get this far */
+    public Object invoke(Object proxy, Method method, Object[] args)
+        throws Throwable {
+
+        return null;
+    }
+}
diff --git a/test/044-proxy/src/Clash3.java b/test/044-proxy/src/Clash3.java
new file mode 100644 (file)
index 0000000..6d6f2f2
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+/*
+ * Try to instantiate a proxy class with interfaces that have conflicting
+ * duplicate methods (type tree with interface).
+ */
+public class Clash3 {
+    public static void main(String[] args) {
+        InvocationHandler handler = new Clash3InvocationHandler();
+
+        try {
+            Proxy.newProxyInstance(Clash.class.getClassLoader(),
+                new Class[] {
+                    Interface3a.class,
+                    Interface3base.class,
+                    Interface3aa.class,
+                    Interface3b.class },
+                handler);
+            System.err.println("Clash3 did not throw expected exception");
+        } catch (IllegalArgumentException iae) {
+            System.out.println("Clash3 threw expected exception");
+        }
+    }
+}
+
+class R3base implements I3 { int mBlah; public void x() {} }
+class R3a extends R3base { int mBlah_a;  }
+class R3aa extends R3a { int mBlah_aa;  }
+class R3b implements I3 { int mBlah_b; public void x() {} }
+
+interface I3 {
+    void x();
+}
+
+interface Interface3base {
+    public R3base thisIsTrouble();
+}
+
+interface Interface3a {
+    public R3a thisIsTrouble();
+}
+interface Interface3aa {
+    public R3aa thisIsTrouble();
+}
+interface Interface3b {
+    public R3b thisIsTrouble();
+}
+
+class Clash3InvocationHandler implements InvocationHandler {
+    /* don't really need to do anything -- should never get this far */
+    public Object invoke(Object proxy, Method method, Object[] args)
+        throws Throwable {
+
+        return null;
+    }
+}
diff --git a/test/044-proxy/src/Clash4.java b/test/044-proxy/src/Clash4.java
new file mode 100644 (file)
index 0000000..1bfb37f
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+/*
+ * Try to instantiate a proxy class with interfaces that have conflicting
+ * duplicate methods (tree of types).
+ */
+public class Clash4 {
+    public static void main(String[] args) {
+        InvocationHandler handler = new Clash4InvocationHandler();
+
+        try {
+            Proxy.newProxyInstance(Clash.class.getClassLoader(),
+                new Class[] {
+                    Interface4a.class,
+                    Interface4aa.class,
+                    Interface4base.class,
+                    Interface4b.class,
+                    Interface4bb.class },
+                handler);
+            System.err.println("Clash4 did not throw expected exception");
+        } catch (IllegalArgumentException iae) {
+            System.out.println("Clash4 threw expected exception");
+            //System.out.println(iae);
+        }
+    }
+}
+
+class R4base { int mBlah;  }
+class R4a extends R4base { int mBlah_a;  }
+class R4aa extends R4a { int mBlah_aa;  }
+class R4b extends R4base { int mBlah_b;  }
+class R4bb extends R4b { int mBlah_bb;  }
+
+interface Interface4base {
+    public R4base thisIsTrouble();
+}
+
+interface Interface4a {
+    public R4a thisIsTrouble();
+}
+interface Interface4aa {
+    public R4aa thisIsTrouble();
+}
+interface Interface4b {
+    public R4b thisIsTrouble();
+}
+interface Interface4bb {
+    public R4bb thisIsTrouble();
+}
+
+class Clash4InvocationHandler implements InvocationHandler {
+    /* don't really need to do anything -- should never get this far */
+    public Object invoke(Object proxy, Method method, Object[] args)
+        throws Throwable {
+
+        return null;
+    }
+}
diff --git a/test/044-proxy/src/Main.java b/test/044-proxy/src/Main.java
new file mode 100644 (file)
index 0000000..01926af
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/**
+ * Test java.lang.reflect.Proxy
+ */
+public class Main {
+    public static void main(String[] args) {
+        BasicTest.main(null);
+        Clash.main(null);
+        Clash2.main(null);
+        Clash3.main(null);
+        Clash4.main(null);
+        WrappedThrow.main(null);
+    }
+}
diff --git a/test/044-proxy/src/WrappedThrow.java b/test/044-proxy/src/WrappedThrow.java
new file mode 100644 (file)
index 0000000..27ae84e
--- /dev/null
@@ -0,0 +1,244 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+import java.io.IOException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.UndeclaredThrowableException;
+
+/*
+ * Create a Proxy class that blah.
+ */
+public class WrappedThrow {
+    public static void main(String[] args) {
+        WTMix mix = new WTMix();
+        InvocationHandler handler = new WTInvocationHandler(mix);
+        Object proxy;
+
+        try {
+            proxy = Proxy.newProxyInstance(WrappedThrow.class.getClassLoader(),
+                new Class[] { InterfaceW1.class, InterfaceW2.class },
+                handler);
+        } catch (IllegalArgumentException iae) {
+            System.out.println("WT init failed");
+            return;
+        }
+
+        InterfaceW1 if1 = (InterfaceW1) proxy;
+        InterfaceW2 if2 = (InterfaceW2) proxy;
+        try {
+            if1.throwFunky();
+            System.err.println("No exception thrown");
+        } catch (UndeclaredThrowableException ute) {
+            System.out.println("Got expected UTE");
+        } catch (Throwable t) {
+            System.err.println("Got unexpected exception: " + t);
+        }
+
+        try {
+            if1.throwFunky2();
+            System.err.println("No exception thrown");
+        } catch (IOException ioe) {
+            System.out.println("Got expected IOE");
+        } catch (Throwable t) {
+            System.err.println("Got unexpected exception: " + t);
+        }
+
+        try {
+            if2.throwFunky2();
+            System.err.println("No exception thrown");
+        } catch (IOException ioe) {
+            System.out.println("Got expected IOE");
+        } catch (Throwable t) {
+            System.err.println("Got unexpected exception: " + t);
+        }
+
+        /*
+         * Throw exceptions, walking down the hierarchy.
+         */
+        try {
+            if1.throwException();
+            System.err.println("No exception thrown");
+        } catch (UndeclaredThrowableException ute) {
+            System.out.println("Got expected UTE");
+        } catch (Throwable t) {
+            System.err.println("Got unexpected exception: " + t);
+        }
+
+        try {
+            if1.throwBase();
+            System.err.println("No exception thrown");
+        } catch (UndeclaredThrowableException ute) {
+            System.out.println("Got expected UTE");
+        } catch (Throwable t) {
+            System.err.println("Got unexpected exception: " + t);
+        }
+
+        try {
+            if2.throwSub();
+            System.err.println("No exception thrown");
+        } catch (SubException se) {
+            System.out.println("Got expected exception");
+        } catch (Throwable t) {
+            System.err.println("Got unexpected exception: " + t);
+        }
+
+        try {
+            if2.throwSubSub();
+            System.err.println("No exception thrown");
+        } catch (SubException se) {
+            System.out.println("Got expected exception");
+        } catch (Throwable t) {
+            System.err.println("Got unexpected exception: " + t);
+        }
+
+        /*
+         * Make sure that, if the class explicitly allows the base
+         * class of an exception, that we still allow it.
+         */
+        try {
+            if1.bothThrowBase();
+            System.err.println("No exception thrown");
+        } catch (BaseException se) {
+            System.out.println("Got expected exception");
+        } catch (Throwable t) {
+            System.err.println("Got unexpected exception: " + t);
+        }
+    }
+}
+
+class BaseException extends Exception {}
+class SubException extends BaseException {}
+class SubSubException extends SubException {}
+
+interface InterfaceW1 {
+    public void throwFunky();
+
+    public void throwFunky2() throws BaseException,
+           NoSuchMethodException, IOException;
+
+    public void throwException() throws BaseException;
+    public void throwBase() throws BaseException;
+    public void throwSub() throws BaseException;
+    public void throwSubSub() throws BaseException;
+
+    public void bothThrowBase() throws BaseException, SubException, SubSubException;
+}
+
+interface InterfaceW2 {
+    public void throwFunky2() throws InterruptedException,
+           NoSuchMethodException, IOException;
+
+    public void throwException() throws SubException;
+    public void throwBase() throws SubException;
+    public void throwSub() throws SubException;
+    public void throwSubSub() throws SubException;
+
+    public void bothThrowBase() throws SubException, BaseException, SubSubException;
+}
+
+/**
+ * Implement all of the proxied interfaces.
+ */
+class WTMix implements InterfaceW1, InterfaceW2 {
+    public int dastardlyDeed() throws SubException {
+        System.out.println("Throwing SubException");
+        throw new SubException();
+    }
+
+    /* these don't actually get called; they just cause exceptions */
+    public void throwFunky() {}
+    public void throwFunky2() {}
+    public void throwException() throws SubException {}
+    public void throwBase() throws SubException {}
+    public void throwSub() throws SubException {}
+    public void throwSubSub() throws SubException {}
+
+    public void bothThrowBase() throws BaseException, SubException {}
+}
+
+/**
+ * Invocation handler for our proxy class.
+ */
+class WTInvocationHandler implements InvocationHandler {
+    private Object mObj;
+
+    public WTInvocationHandler(Object obj) {
+        mObj = obj;
+    }
+
+    /*
+     * This is called when anything gets invoked in the proxy object.
+     */
+    public Object invoke(Object proxy, Method method, Object[] args)
+        throws Throwable {
+
+        Object result = null;
+
+        // Trap Object calls.  This is important here to avoid a recursive
+        // invocation of toString() in the print statements below.
+        if (method.getDeclaringClass() == java.lang.Object.class) {
+            //System.out.println("!!! object " + method.getName());
+            if (method.getName().equals("toString"))
+                return super.toString();
+            else if (method.getName().equals("hashCode"))
+                return Integer.valueOf(super.hashCode());
+            else if (method.getName().equals("equals"))
+                return Boolean.valueOf(super.equals(args[0]));
+            else
+                throw new RuntimeException("huh?");
+        }
+
+        System.out.println("Invoke " + method);
+        if (args == null || args.length == 0) {
+            System.out.println(" (no args)");
+        } else {
+            for (int i = 0; i < args.length; i++)
+                System.out.println(" " + i + ": " + args[i]);
+        }
+
+        try {
+            if (method.getName().equals("throwFunky"))
+                throw new InterruptedException("fake");
+            if (method.getName().equals("throwFunky2"))
+                throw new IOException("fake2");
+            if (method.getName().equals("throwException"))
+                throw new Exception();
+            if (method.getName().equals("throwBase"))
+                throw new BaseException();
+            if (method.getName().equals("throwSub"))
+                throw new SubException();
+            if (method.getName().equals("throwSubSub"))
+                throw new SubSubException();
+            if (method.getName().equals("bothThrowBase"))
+                throw new BaseException();
+
+            if (true)
+                result = method.invoke(mObj, args);
+            else
+                result = -1;
+            System.out.println("Success: method " + method.getName()
+                + " res=" + result);
+        } catch (InvocationTargetException ite) {
+            throw ite.getTargetException();
+        } catch (IllegalAccessException iae) {
+            throw new RuntimeException(iae);
+        }
+        return result;
+    }
+}
diff --git a/test/045-reflect-array/expected.txt b/test/045-reflect-array/expected.txt
new file mode 100644 (file)
index 0000000..5c609b5
--- /dev/null
@@ -0,0 +1,6 @@
+ReflectArrayTest.testSingleInt passed
+ReflectArrayTest.testSingle passed
+ReflectArrayTest.testMultiInt passed
+zero one two ++
+ReflectArrayTest.testMulti passed
+ReflectArrayTest passed
diff --git a/test/045-reflect-array/info.txt b/test/045-reflect-array/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/045-reflect-array/src/Main.java b/test/045-reflect-array/src/Main.java
new file mode 100644 (file)
index 0000000..c70e291
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2006 The Android Open Source Project
+ */
+
+import java.lang.reflect.Array;
+
+/**
+ * Test java.lang.reflect.Array.
+ */
+public class Main {
+    public static void main(String[] args) {
+        testSingleInt();
+        testSingle();
+        testMultiInt();
+        testMulti();
+
+        System.out.println("ReflectArrayTest passed");
+    }
+
+    static void testSingleInt() {
+        Object intArray;
+
+        intArray = Array.newInstance(Integer.TYPE, 2);
+
+        int[] array = (int[]) intArray;
+        array[0] = 5;
+        Array.setInt(intArray, 1, 6);
+
+        if (Array.getInt(intArray, 0) != 5)
+            throw new RuntimeException();
+        if (array[1] != 6)
+            throw new RuntimeException();
+        try {
+            array[2] = 27;
+            throw new RuntimeException("store should have failed");
+        }
+        catch (ArrayIndexOutOfBoundsException abe) {
+        }
+        if (array.length != Array.getLength(intArray) ||
+            array.length != 2)
+        {
+            throw new RuntimeException("bad len");
+        }
+
+        int[][] wrongArray;
+        try {
+            wrongArray = (int[][]) intArray;
+            throw new RuntimeException("cast should have failed");
+        }
+        catch (ClassCastException cce) {
+        }
+
+        intArray = Array.newInstance(Integer.TYPE, 0);
+        if (Array.getLength(intArray) != 0)
+            throw new RuntimeException();
+        System.out.println("ReflectArrayTest.testSingleInt passed");
+    }
+
+    static void testSingle() {
+        Object strArray;
+
+        strArray = Array.newInstance(String.class, 2);
+
+        String[] array = (String[]) strArray;
+        array[0] = "entry zero";
+        Array.set(strArray, 1, "entry one");
+
+        //System.out.println("array: " + array);
+
+        if (!"entry zero".equals(Array.get(strArray, 0)))
+            throw new RuntimeException();
+        if (!"entry one".equals(array[1]))
+            throw new RuntimeException();
+
+        if (array.length != Array.getLength(strArray) ||
+            array.length != 2)
+        {
+            throw new RuntimeException("bad len");
+        }
+        System.out.println("ReflectArrayTest.testSingle passed");
+    }
+
+    static void testMultiInt() {
+        Object intIntIntArray;
+        int[] dimensions = { 3, 2, 1 };
+
+        intIntIntArray = Array.newInstance(Integer.TYPE, dimensions);
+        int[][][] array3 = (int[][][]) intIntIntArray;
+
+        array3[0][0][0] = 123;      // trouble
+        array3[2][1][0] = 456;
+
+        try {
+            array3[2][1][1] = 768;
+            throw new RuntimeException("store should have failed");
+        }
+        catch (ArrayIndexOutOfBoundsException abe) {
+        }
+        System.out.println("ReflectArrayTest.testMultiInt passed");
+    }
+
+    static void testMulti() {
+        Object strStrStrArray;
+        int[] dimensions = { 1, 2, 3 };
+
+        strStrStrArray = Array.newInstance(String.class, dimensions);
+        String[][][] array3 = (String[][][]) strStrStrArray;
+
+        array3[0][0][0] = "zero zero zero";
+        array3[0][1][2] = "zero one two";
+
+        try {
+            array3[1][0][0] = "bad store";
+            throw new RuntimeException("store should have failed");
+        }
+        catch (ArrayIndexOutOfBoundsException abe) {
+        }
+
+        try {
+            String[][] array2 = (String[][]) strStrStrArray;
+            throw new RuntimeException("expecting bad cast");
+        }
+        catch (ClassCastException cce) {
+        }
+
+        String[] strar = new String[4];
+        strar[2] = "zero one two ++";
+        array3[0][1] = strar;
+        System.out.println(array3[0][1][2]);
+        //System.out.println("array3: " + array3);
+
+
+        int[] dimensions2 = { 1, 2 };
+        strStrStrArray = Array.newInstance(String[].class, dimensions2);
+        array3 = (String[][][]) strStrStrArray;
+
+        array3[0][1] = new String[3];
+        array3[0][1][2] = "zero one two";
+        try {
+            array3[1][0][0] = "bad store";
+            throw new RuntimeException("store should have failed");
+        }
+        catch (ArrayIndexOutOfBoundsException abe) {
+        }
+        System.out.println("ReflectArrayTest.testMulti passed");
+    }
+}
diff --git a/test/046-reflect/expected.txt b/test/046-reflect/expected.txt
new file mode 100644 (file)
index 0000000..55b0eca
--- /dev/null
@@ -0,0 +1,97 @@
+Method name is myMethod
+ Declaring class is Target
+ Arg 0: int
+ Exc 0: java.lang.NullPointerException
+ Exc 1: java.io.IOException
+ Return type is int
+ Access flags are 0x1
+Method name is myMethod
+ Declaring class is SuperTarget
+ Arg 0: float
+ Return type is int
+ Access flags are 0x1
+Method name is myNoargMethod
+ Declaring class is Target
+ Return type is void
+ Access flags are 0x9
+Method name is myMethod
+ Declaring class is Target
+ Arg 0: [Ljava.lang.String;
+ Arg 1: float
+ Arg 2: char
+ Return type is int
+ Access flags are 0x1
+SuperTarget constructor ()V
+Target constructor ()V
+Before, float is 3.1415925
+myMethod: hi there 3.1415925 Q !
+Result of invoke: 7
+Calling no-arg void-return method
+myNoargMethod ()V
+throwingMethod
+Invoke got expected exception:
+java.lang.reflect.InvocationTargetException
+java.lang.NullPointerException: gratuitous throw!
+
+Field name is string1
+ Declaring class is Target
+ Field type is java.lang.String
+ Access flags are 0x1
+  string1 value is 'hey'
+  ::: hey:yo:there
+  string1 value is now 'a new string'
+  ::: a new string:yo:there
+  got expected illegal obj store exc
+  got the other expected access exc
+  got expected arg exc
+pubLong initial value is 1122334455667788
+pubLong new value is 9988776655443322
+Field name is superInt
+ Declaring class is SuperTarget
+ Field type is int
+ Access flags are 0x1
+  superInt value is 1010101
+  superInt boxed is 1010101
+  superInt value is now 20202
+  superInt value (from short) is now 30303
+  superInt value is now 40404
+  got expected long->int failure
+  got expected long->int failure
+  got expected string->int failure
+  got expected int->short failure
+Field name is superClassInt
+ Declaring class is SuperTarget
+ Field type is int
+ Access flags are 0x9
+  superClassInt value is 1010102
+Field name is staticDouble
+ Declaring class is Target
+ Field type is double
+ Access flags are 0x9
+  staticDoubleVal value is 3.3
+  got expected double->long failure
+as expected: aPrivateInt not found
+Field name is constantString
+ Declaring class is Target
+ Field type is java.lang.String
+ Access flags are 0x19
+  Constant test value is a constant string
+Field name is cantTouchThis
+ Declaring class is Target
+ Field type is int
+ Access flags are 0x11
+  cantTouchThis is 77
+  got expected set-final failure
+  cantTouchThis is now 77
+  cantTouchThis is now 88
+cons modifiers=1
+SuperTarget constructor ()V
+Target constructor (IF)V : ii=7 ff=3.3333
+myMethod (I)I
+ arg=17 anInt=7
+ReflectTest done!
+checkType invoking null
+checkType got expected exception
+got methods
+NoisyInitUser is initializing
+NoisyInit is initializing
diff --git a/test/046-reflect/info.txt b/test/046-reflect/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/046-reflect/src/Main.java b/test/046-reflect/src/Main.java
new file mode 100644 (file)
index 0000000..e604979
--- /dev/null
@@ -0,0 +1,441 @@
+// Copyright 2006 The Android Open Source Project
+
+import java.lang.reflect.*;
+import java.io.IOException;
+import java.util.Collections;
+
+/**
+ * Reflection test.
+ */
+public class Main {
+    void printMethodInfo(Method meth) {
+        Class[] params, exceptions;
+        int i;
+
+        System.out.println("Method name is " + meth.getName());
+        System.out.println(" Declaring class is "
+            + meth.getDeclaringClass().getName());
+        params = meth.getParameterTypes();
+        for (i = 0; i < params.length; i++)
+            System.out.println(" Arg " + i + ": " + params[i].getName());
+        exceptions = meth.getExceptionTypes();
+        for (i = 0; i < exceptions.length; i++)
+            System.out.println(" Exc " + i + ": " + exceptions[i].getName());
+        System.out.println(" Return type is " + meth.getReturnType().getName());
+        System.out.println(" Access flags are 0x"
+            + Integer.toHexString(meth.getModifiers()));
+        //System.out.println(" GenericStr is " + meth.toGenericString());
+    }
+
+    void printFieldInfo(Field field) {
+        System.out.println("Field name is " + field.getName());
+        System.out.println(" Declaring class is "
+            + field.getDeclaringClass().getName());
+        System.out.println(" Field type is " + field.getType().getName());
+        System.out.println(" Access flags are 0x"
+            + Integer.toHexString(field.getModifiers()));
+    }
+
+    private void showStrings(Target instance)
+        throws NoSuchFieldException, IllegalAccessException {
+
+        Class target = Target.class;
+        String one, two, three, four;
+        Field field = null;
+
+        field = target.getField("string1");
+        one = (String) field.get(instance);
+
+        field = target.getField("string2");
+        two = (String) field.get(instance);
+
+        field = target.getField("string3");
+        three = (String) field.get(instance);
+
+        System.out.println("  ::: " + one + ":" + two + ":" + three);
+    }
+
+    public void run() {
+        Class target = Target.class;
+        Method meth = null;
+        Field field = null;
+        boolean excep;
+
+        try {
+            meth = target.getMethod("myMethod", new Class[] { int.class });
+
+            if (meth.getDeclaringClass() != target)
+                throw new RuntimeException();
+            printMethodInfo(meth);
+
+            meth = target.getMethod("myMethod", new Class[] { float.class });
+            printMethodInfo(meth);
+
+            meth = target.getMethod("myNoargMethod", (Class[]) null);
+            printMethodInfo(meth);
+
+            meth = target.getMethod("myMethod",
+                new Class[] { String[].class, float.class, char.class });
+            printMethodInfo(meth);
+
+            Target instance = new Target();
+            Object[] argList = new Object[] {
+                new String[] { "hi there" },
+                new Float(3.1415926f),
+                new Character('Q')
+            };
+            System.out.println("Before, float is "
+                + ((Float)argList[1]).floatValue());
+
+            Integer boxval;
+            boxval = (Integer) meth.invoke(instance, argList);
+            System.out.println("Result of invoke: " + boxval.intValue());
+
+            System.out.println("Calling no-arg void-return method");
+            meth = target.getMethod("myNoargMethod", (Class[]) null);
+            meth.invoke(instance, (Object[]) null);
+
+            /* try invoking a method that throws an exception */
+            meth = target.getMethod("throwingMethod", (Class[]) null);
+            try {
+                meth.invoke(instance, (Object[]) null);
+                System.out.println("GLITCH: didn't throw");
+            } catch (InvocationTargetException ite) {
+                System.out.println("Invoke got expected exception:");
+                System.out.println(ite.getClass().getName());
+                System.out.println(ite.getCause());
+            }
+            catch (Exception ex) {
+                System.out.println("GLITCH: invoke got wrong exception:");
+                ex.printStackTrace();
+            }
+            System.out.println("");
+
+
+            field = target.getField("string1");
+            if (field.getDeclaringClass() != target)
+                throw new RuntimeException();
+            printFieldInfo(field);
+            String strVal = (String) field.get(instance);
+            System.out.println("  string1 value is '" + strVal + "'");
+
+            showStrings(instance);
+
+            field.set(instance, new String("a new string"));
+            strVal = (String) field.get(instance);
+            System.out.println("  string1 value is now '" + strVal + "'");
+
+            showStrings(instance);
+
+            try {
+                field.set(instance, new Object());
+                System.out.println("WARNING: able to store Object into String");
+            }
+            catch (IllegalArgumentException iae) {
+                System.out.println("  got expected illegal obj store exc");
+            }
+
+
+            try {
+                String four;
+                field = target.getField("string4");
+                four = (String) field.get(instance);
+                System.out.println("WARNING: able to access string4: "
+                    + four);
+            }
+            catch (IllegalAccessException iae) {
+                System.out.println("  got expected access exc");
+            }
+            catch (NoSuchFieldException nsfe) {
+                System.out.println("  got the other expected access exc");
+            }
+            try {
+                String three;
+                field = target.getField("string3");
+                three = (String) field.get(this);
+                System.out.println("WARNING: able to get string3 in wrong obj: "
+                    + three);
+            }
+            catch (IllegalArgumentException iae) {
+                System.out.println("  got expected arg exc");
+            }
+
+            /*
+             * Try setting a field to null.
+             */
+            String four;
+            field = target.getDeclaredField("string3");
+            field.set(instance, null);
+
+            /*
+             * Do some stuff with long.
+             */
+            long longVal;
+            field = target.getField("pubLong");
+            longVal = field.getLong(instance);
+            System.out.println("pubLong initial value is " +
+                Long.toHexString(longVal));
+            field.setLong(instance, 0x9988776655443322L);
+            longVal = field.getLong(instance);
+            System.out.println("pubLong new value is " +
+                Long.toHexString(longVal));
+
+
+            field = target.getField("superInt");
+            if (field.getDeclaringClass() == target)
+                throw new RuntimeException();
+            printFieldInfo(field);
+            int intVal = field.getInt(instance);
+            System.out.println("  superInt value is " + intVal);
+            Integer boxedIntVal = (Integer) field.get(instance);
+            System.out.println("  superInt boxed is " + boxedIntVal);
+
+            field.set(instance, new Integer(20202));
+            intVal = field.getInt(instance);
+            System.out.println("  superInt value is now " + intVal);
+            field.setShort(instance, (short)30303);
+            intVal = field.getInt(instance);
+            System.out.println("  superInt value (from short) is now " +intVal);
+            field.setInt(instance, 40404);
+            intVal = field.getInt(instance);
+            System.out.println("  superInt value is now " + intVal);
+            try {
+                field.set(instance, new Long(123));
+                System.out.println("FAIL: expected exception not thrown");
+            }
+            catch (IllegalArgumentException iae) {
+                System.out.println("  got expected long->int failure");
+            }
+            try {
+                field.setLong(instance, 123);
+                System.out.println("FAIL: expected exception not thrown");
+            }
+            catch (IllegalArgumentException iae) {
+                System.out.println("  got expected long->int failure");
+            }
+            try {
+                field.set(instance, new String("abc"));
+                System.out.println("FAIL: expected exception not thrown");
+            }
+            catch (IllegalArgumentException iae) {
+                System.out.println("  got expected string->int failure");
+            }
+
+            try {
+                field.getShort(instance);
+                System.out.println("FAIL: expected exception not thrown");
+            }
+            catch (IllegalArgumentException iae) {
+                System.out.println("  got expected int->short failure");
+            }
+
+            field = target.getField("superClassInt");
+            printFieldInfo(field);
+            int superClassIntVal = field.getInt(instance);
+            System.out.println("  superClassInt value is " + superClassIntVal);
+
+            field = target.getField("staticDouble");
+            printFieldInfo(field);
+            double staticDoubleVal = field.getDouble(null);
+            System.out.println("  staticDoubleVal value is " + staticDoubleVal);
+
+            try {
+                field.getLong(instance);
+                System.out.println("FAIL: expected exception not thrown");
+            }
+            catch (IllegalArgumentException iae) {
+                System.out.println("  got expected double->long failure");
+            }
+
+            excep = false;
+            try {
+                field = target.getField("aPrivateInt");
+                printFieldInfo(field);
+            }
+            catch (NoSuchFieldException nsfe) {
+                System.out.println("as expected: aPrivateInt not found");
+                excep = true;
+            }
+            if (!excep)
+                System.out.println("BUG: got aPrivateInt");
+
+
+            field = target.getField("constantString");
+            printFieldInfo(field);
+            String val = (String) field.get(instance);
+            System.out.println("  Constant test value is " + val);
+
+
+            field = target.getField("cantTouchThis");
+            printFieldInfo(field);
+            intVal = field.getInt(instance);
+            System.out.println("  cantTouchThis is " + intVal);
+            try {
+                field.setInt(instance, 99);
+                System.out.println("ERROR: set-final succeeded");
+            } catch (IllegalAccessException iae) {
+                System.out.println("  got expected set-final failure");
+            }
+            intVal = field.getInt(instance);
+            System.out.println("  cantTouchThis is now " + intVal);
+
+            field.setAccessible(true);
+            field.setInt(instance, 87);     // exercise int version
+            field.set(instance, 88);        // exercise Object version
+            intVal = field.getInt(instance);
+            System.out.println("  cantTouchThis is now " + intVal);
+
+            Constructor<Target> cons;
+            Target targ;
+            Object[] args;
+
+            cons = target.getConstructor(new Class[] { int.class,float.class });
+            args = new Object[] { new Integer(7), new Float(3.3333) };
+            System.out.println("cons modifiers=" + cons.getModifiers());
+            targ = cons.newInstance(args);
+            targ.myMethod(17);
+
+        }
+        catch (Exception ex) {
+            System.out.println("----- unexpected exception -----");
+            ex.printStackTrace();
+        }
+
+        System.out.println("ReflectTest done!");
+    }
+
+    public static void checkType() {
+        Method m;
+
+        try {
+            m = Collections.class.getDeclaredMethod("checkType",
+                            Object.class, Class.class);
+        } catch (NoSuchMethodException nsme) {
+            nsme.printStackTrace();
+            return;
+        }
+
+        m.setAccessible(true);
+        try {
+            m.invoke(null, new Object(), Object.class);
+        } catch (IllegalAccessException iae) {
+            iae.printStackTrace();
+            return;
+        } catch (InvocationTargetException ite) {
+            ite.printStackTrace();
+            return;
+        }
+
+        try {
+            System.out.println("checkType invoking null");
+            m.invoke(null, new Object(), int.class);
+            System.out.println("ERROR: should throw InvocationTargetException");
+        } catch (InvocationTargetException ite) {
+            System.out.println("checkType got expected exception");
+        } catch (IllegalAccessException iae) {
+            iae.printStackTrace();
+            return;
+        }
+    }
+
+    public static void checkInit() {
+        Class niuClass = NoisyInitUser.class;
+        Method[] methods;
+
+        methods = niuClass.getDeclaredMethods();
+        System.out.println("got methods");
+        /* neither NoisyInit nor NoisyInitUser should be initialized yet */
+        NoisyInitUser niu = new NoisyInitUser();
+        NoisyInit ni = new NoisyInit();
+    }
+
+    public static void main(String[] args) {
+        Main test = new Main();
+        test.run();
+
+        checkType();
+        checkInit();
+    }
+}
+
+
+class SuperTarget {
+    public SuperTarget() {
+        System.out.println("SuperTarget constructor ()V");
+        superInt = 1010101;
+        superClassInt = 1010102;
+    }
+
+    public int myMethod(float floatArg) {
+        System.out.println("myMethod (F)I " + floatArg);
+        return 6;
+    }
+
+    public int superInt;
+    public static int superClassInt;
+}
+
+class Target extends SuperTarget {
+    public Target() {
+        System.out.println("Target constructor ()V");
+    }
+
+    public Target(int ii, float ff) {
+        System.out.println("Target constructor (IF)V : ii="
+            + ii + " ff=" + ff);
+        anInt = ii;
+    }
+
+    public int myMethod(int intarg) throws NullPointerException, IOException {
+        System.out.println("myMethod (I)I");
+        System.out.println(" arg=" + intarg + " anInt=" + anInt);
+        return 5;
+    }
+
+    public int myMethod(String[] strarg, float f, char c) {
+        System.out.println("myMethod: " + strarg[0] + " " + f + " " + c + " !");
+        return 7;
+    }
+
+    public static void myNoargMethod() {
+        System.out.println("myNoargMethod ()V");
+    }
+
+    public void throwingMethod() {
+        System.out.println("throwingMethod");
+        throw new NullPointerException("gratuitous throw!");
+    }
+
+    public void misc() {
+        System.out.println("misc");
+    }
+
+    public int anInt;
+    public String string1 = "hey";
+    public String string2 = "yo";
+    public String string3 = "there";
+    private String string4 = "naughty";
+    public static final String constantString = "a constant string";
+    private int aPrivateInt;
+
+    public final int cantTouchThis = 77;
+
+    public long pubLong = 0x1122334455667788L;
+
+    public static double staticDouble = 3.3;
+}
+
+class NoisyInit {
+    static {
+        System.out.println("NoisyInit is initializing");
+        //Throwable th = new Throwable();
+        //th.printStackTrace();
+    }
+}
+
+class NoisyInitUser {
+    static {
+        System.out.println("NoisyInitUser is initializing");
+    }
+    public void createNoisyInit(NoisyInit ni) {}
+}
diff --git a/test/047-returns/expected.txt b/test/047-returns/expected.txt
new file mode 100644 (file)
index 0000000..160f69c
--- /dev/null
@@ -0,0 +1,10 @@
+pick 1
+one running
+one
+1
+pick 2
+two running
+two
+2
+pick 3
+three running
diff --git a/test/047-returns/info.txt b/test/047-returns/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/047-returns/src/Main.java b/test/047-returns/src/Main.java
new file mode 100644 (file)
index 0000000..d53c4a7
--- /dev/null
@@ -0,0 +1,65 @@
+// Copyright 2007 The Android Open Source Project
+
+/**
+ * Return stuff.
+ */
+public class Main {
+    public static void main(String[] args) {
+
+        System.out.println("pick 1");
+        pickOne(1).run();
+        System.out.println(((CommonInterface)pickOne(1)).doStuff());
+
+        System.out.println("pick 2");
+        pickOne(2).run();
+        System.out.println(((CommonInterface)pickOne(2)).doStuff());
+
+        System.out.println("pick 3");
+        pickOne(3).run();
+    }
+
+    public static Runnable pickOne(int which) {
+        Runnable runme;
+
+        if (which == 1)
+            runme = new ClassOne();
+        else if (which == 2)
+            runme = new ClassTwo();
+        else if (which == 3)
+            runme = new ClassThree();
+        else
+            runme = null;
+
+        return runme;
+    }
+}
+
+class ClassOne implements CommonInterface, Runnable {
+    public void run() {
+        System.out.println("one running");
+    }
+    public int doStuff() {
+        System.out.println("one");
+        return 1;
+    }
+}
+
+class ClassTwo implements CommonInterface, Runnable {
+    public void run() {
+        System.out.println("two running");
+    }
+    public int doStuff() {
+        System.out.println("two");
+        return 2;
+    }
+}
+
+class ClassThree implements Runnable {
+    public void run() {
+        System.out.println("three running");
+    }
+}
+
+interface CommonInterface {
+    int doStuff();
+}
diff --git a/test/048-server-socket/expected.txt b/test/048-server-socket/expected.txt
new file mode 100644 (file)
index 0000000..23c3e84
--- /dev/null
@@ -0,0 +1,4 @@
+opened!
+closed!
+reopened!
+done
diff --git a/test/048-server-socket/info.txt b/test/048-server-socket/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/048-server-socket/src/Main.java b/test/048-server-socket/src/Main.java
new file mode 100644 (file)
index 0000000..55dbf9a
--- /dev/null
@@ -0,0 +1,52 @@
+// Copyright 2007 The Android Open Source Project
+
+import java.net.ServerSocket;
+import java.io.IOException;
+
+
+/**
+ * Quick server socket test.
+ */
+public class Main {
+    private static void snooze(int sec) {
+        try {
+            Thread.sleep(sec * 1000);
+        } catch (InterruptedException ie) {
+            ie.printStackTrace();
+        }
+    }
+
+    public static void main(String[] args) {
+        ServerSocket socket;
+
+        try {
+            socket = new ServerSocket(7890);
+        } catch (IOException ioe) {
+            System.out.println("couldn't open socket " + ioe.getMessage());
+            return;
+        }
+
+        System.out.println("opened!");
+        snooze(1);
+
+        try {
+            socket.close();
+        } catch (IOException ioe) {
+            System.out.println("couldn't close socket " + ioe.getMessage());
+            return;
+        }
+
+        System.out.println("closed!");
+        snooze(1);
+
+        try {
+            socket = new ServerSocket(7890);
+        } catch (IOException ioe) {
+            System.out.println("couldn't reopen socket " + ioe.getMessage());
+            return;
+        }
+
+        System.out.println("reopened!");
+        System.out.println("done");
+    }
+}
diff --git a/test/049-show-object/expected.txt b/test/049-show-object/expected.txt
new file mode 100644 (file)
index 0000000..4613c39
--- /dev/null
@@ -0,0 +1,11 @@
+d is 3.1415
+class: class [Ljava.lang.Object;
+0: null
+1: null
+2: null
+3: null
+4: null
+class: class [Ljava.lang.String;
+0: hey
+1: you
+2: there
diff --git a/test/049-show-object/info.txt b/test/049-show-object/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/049-show-object/src/Main.java b/test/049-show-object/src/Main.java
new file mode 100644 (file)
index 0000000..d31eeda
--- /dev/null
@@ -0,0 +1,34 @@
+// Copyright 2008 The Android Open Source Project
+
+/*
+ * Some basic operations for testing the debugger.
+ */
+public class Main {
+    long mLong = 0x1122334455667788L;
+
+    public Main() {
+        double d = 3.1415;
+        System.out.println("d is " + d);
+    }
+
+    public static void showObject(Object[] foo) {
+        int xyz = 27;
+        System.out.println("class: " + foo.getClass());
+
+        for (int i = 0; i < foo.length; i++) {
+            System.out.println(i + ": "  + foo[i]);
+        }
+    }
+
+    public static void main(String[] args) {
+        int x = 5;
+        Main testObj = new Main();
+
+        Object[] array = new Object[5];
+        showObject(array);
+
+        String[] niftyStrings = new String[] { "hey", "you", "there" };
+        array = niftyStrings;
+        showObject(array);
+    }
+}
diff --git a/test/050-sync-test/expected.txt b/test/050-sync-test/expected.txt
new file mode 100644 (file)
index 0000000..c2a7031
--- /dev/null
@@ -0,0 +1,34 @@
+Sleep Test
+GOING
+GONE
+
+Count Test
+going: 1
+going: 1
+going: 1
+going: 1
+going: 1
+going: 1
+going: 1
+going: 1
+going: 1
+going: 1
+Final result: 10
+going: 2
+going: 2
+going: 2
+going: 2
+going: 2
+going: 2
+going: 2
+going: 2
+going: 2
+going: 2
+Final result: 20
+main: all done
+
+Interrupt Test
+SleepyThread.run starting
+SleepyThread.run starting
+interrupting other (isAlive=true)
+thread#0 interrupted, flag=false
diff --git a/test/050-sync-test/info.txt b/test/050-sync-test/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/050-sync-test/src/Main.java b/test/050-sync-test/src/Main.java
new file mode 100644 (file)
index 0000000..c2ea192
--- /dev/null
@@ -0,0 +1,179 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Test synchronization primitives.
+ *
+ * TODO: this should be re-written to be a little more rigorous and/or
+ * useful.  Also, the ThreadDeathHandler stuff should be exposed or
+ * split out.
+ */
+public class Main {
+    public static void main(String[] args) {
+        System.out.println("Sleep Test");
+        sleepTest();
+
+        System.out.println("\nCount Test");
+        countTest();
+
+        System.out.println("\nInterrupt Test");
+        interruptTest();
+    }
+
+    static void sleepTest() {
+        System.out.println("GOING");
+        try {
+            Thread.sleep(1000);
+        }
+        catch (InterruptedException ie) {
+            System.out.println("INTERRUPT!");
+            ie.printStackTrace();
+        }
+        System.out.println("GONE");
+    }
+
+    static void countTest() {
+        CpuThread one, two;
+
+        one = new CpuThread(1);
+        two = new CpuThread(2);
+
+        one.start();
+        two.start();
+
+        try {
+            Thread.sleep(100);
+        }
+        catch (InterruptedException ie) {
+            System.out.println("INTERRUPT!");
+            ie.printStackTrace();
+        }
+
+        //System.out.println("main: off and running");
+
+        try {
+            one.join();
+            two.join();
+        }
+        catch (InterruptedException ie) {
+            System.out.println("INTERRUPT!");
+            ie.printStackTrace();
+        }
+        System.out.println("main: all done");
+    }
+
+    static void interruptTest() {
+        SleepyThread sleepy, pesky;
+
+        sleepy = new SleepyThread(null);
+        pesky = new SleepyThread(sleepy);
+
+        sleepy.setPriority(4);
+        sleepy.start();
+        pesky.start();
+        pesky.setPriority(3);
+    }
+}
+
+class CpuThread extends Thread {
+    static Object mSyncable = new Object();
+    static int mCount = 0;
+    int mNumber;
+
+    CpuThread(int num) {
+        super("CpuThread " + num);
+        mNumber = num;
+    }
+
+    public void run() {
+        //System.out.print("thread running -- ");
+        //System.out.println(Thread.currentThread().getName());
+
+        for (int i = 0; i < 10; i++) {
+            output(mNumber);
+        }
+
+        System.out.print("Final result: ");
+        System.out.println(mCount);
+    }
+
+    void output(int num) {
+        /*
+         * Delete the next line; last "final result" should != 20.
+         */
+        synchronized (mSyncable)
+        {
+            int i, count;
+
+            count = mCount;
+
+            System.out.print("going: ");
+            System.out.println(num);
+
+            /* burn CPU; adjust end value so we exceed scheduler quantum */
+            for (int j = 0; j < 5000; j++)
+                ;
+
+            count++;
+            mCount = count;
+        }
+    }
+}
+
+class SleepyThread extends Thread {
+    private SleepyThread mOther;
+    private Integer[] mWaitOnMe;      // any type of object will do
+
+    private static int count = 0;
+
+    SleepyThread(SleepyThread other) {
+        mOther = other;
+        mWaitOnMe = new Integer[] { 1, 2 };
+
+        setName("thread#" + count);
+        count++;
+    }
+
+    public void run() {
+        System.out.println("SleepyThread.run starting");
+
+        if (false) {
+            ThreadDeathHandler threadHandler =
+                new ThreadDeathHandler("SYNC THREAD");
+            Thread.currentThread().setUncaughtExceptionHandler(threadHandler);
+            throw new NullPointerException("die");
+        }
+
+        if (mOther == null) {
+            boolean intr = false;
+
+            try {
+                synchronized (mWaitOnMe) {
+                    mWaitOnMe.wait(9000);
+                }
+            }
+            catch (InterruptedException ie) {
+                // Expecting this; interrupted should be false.
+                System.out.println(Thread.currentThread().getName() +
+                        " interrupted, flag=" + Thread.interrupted());
+                intr = true;
+            }
+            catch (Exception ex) {
+                ex.printStackTrace();
+            }
+
+            if (!intr)
+                System.out.println("NOT INTERRUPTED");
+        } else {
+            try {
+                Thread.sleep(2000);
+            }
+            catch (InterruptedException ie) {
+                System.out.println("PESKY INTERRUPTED?");
+            }
+
+            System.out.println("interrupting other (isAlive="
+                + mOther.isAlive() + ")");
+            mOther.interrupt();
+        }
+    }
+}
diff --git a/test/050-sync-test/src/ThreadDeathHandler.java b/test/050-sync-test/src/ThreadDeathHandler.java
new file mode 100644 (file)
index 0000000..5ea61a5
--- /dev/null
@@ -0,0 +1,19 @@
+// Copyright 2007 The Android Open Source Project
+
+import java.lang.Thread.UncaughtExceptionHandler;
+
+/**
+ * Report death-by-uncaught-exception.
+ */
+public class ThreadDeathHandler implements Thread.UncaughtExceptionHandler {
+    private String mMyMessage;
+
+    public ThreadDeathHandler(String msg) {
+        mMyMessage = msg;
+    }
+
+    public void uncaughtException(Thread t, Throwable e) {
+        System.err.println("Uncaught exception " + mMyMessage + "!");
+        e.printStackTrace();
+    }
+}
diff --git a/test/051-thread/expected.txt b/test/051-thread/expected.txt
new file mode 100644 (file)
index 0000000..fbe32f6
--- /dev/null
@@ -0,0 +1,518 @@
+running 0
+running 1
+running 2
+running 3
+running 4
+running 5
+running 6
+running 7
+running 8
+running 9
+running 10
+running 11
+running 12
+running 13
+running 14
+running 15
+running 16
+running 17
+running 18
+running 19
+running 20
+running 21
+running 22
+running 23
+running 24
+running 25
+running 26
+running 27
+running 28
+running 29
+running 30
+running 31
+running 32
+running 33
+running 34
+running 35
+running 36
+running 37
+running 38
+running 39
+running 40
+running 41
+running 42
+running 43
+running 44
+running 45
+running 46
+running 47
+running 48
+running 49
+running 50
+running 51
+running 52
+running 53
+running 54
+running 55
+running 56
+running 57
+running 58
+running 59
+running 60
+running 61
+running 62
+running 63
+running 64
+running 65
+running 66
+running 67
+running 68
+running 69
+running 70
+running 71
+running 72
+running 73
+running 74
+running 75
+running 76
+running 77
+running 78
+running 79
+running 80
+running 81
+running 82
+running 83
+running 84
+running 85
+running 86
+running 87
+running 88
+running 89
+running 90
+running 91
+running 92
+running 93
+running 94
+running 95
+running 96
+running 97
+running 98
+running 99
+running 100
+running 101
+running 102
+running 103
+running 104
+running 105
+running 106
+running 107
+running 108
+running 109
+running 110
+running 111
+running 112
+running 113
+running 114
+running 115
+running 116
+running 117
+running 118
+running 119
+running 120
+running 121
+running 122
+running 123
+running 124
+running 125
+running 126
+running 127
+running 128
+running 129
+running 130
+running 131
+running 132
+running 133
+running 134
+running 135
+running 136
+running 137
+running 138
+running 139
+running 140
+running 141
+running 142
+running 143
+running 144
+running 145
+running 146
+running 147
+running 148
+running 149
+running 150
+running 151
+running 152
+running 153
+running 154
+running 155
+running 156
+running 157
+running 158
+running 159
+running 160
+running 161
+running 162
+running 163
+running 164
+running 165
+running 166
+running 167
+running 168
+running 169
+running 170
+running 171
+running 172
+running 173
+running 174
+running 175
+running 176
+running 177
+running 178
+running 179
+running 180
+running 181
+running 182
+running 183
+running 184
+running 185
+running 186
+running 187
+running 188
+running 189
+running 190
+running 191
+running 192
+running 193
+running 194
+running 195
+running 196
+running 197
+running 198
+running 199
+running 200
+running 201
+running 202
+running 203
+running 204
+running 205
+running 206
+running 207
+running 208
+running 209
+running 210
+running 211
+running 212
+running 213
+running 214
+running 215
+running 216
+running 217
+running 218
+running 219
+running 220
+running 221
+running 222
+running 223
+running 224
+running 225
+running 226
+running 227
+running 228
+running 229
+running 230
+running 231
+running 232
+running 233
+running 234
+running 235
+running 236
+running 237
+running 238
+running 239
+running 240
+running 241
+running 242
+running 243
+running 244
+running 245
+running 246
+running 247
+running 248
+running 249
+running 250
+running 251
+running 252
+running 253
+running 254
+running 255
+running 256
+running 257
+running 258
+running 259
+running 260
+running 261
+running 262
+running 263
+running 264
+running 265
+running 266
+running 267
+running 268
+running 269
+running 270
+running 271
+running 272
+running 273
+running 274
+running 275
+running 276
+running 277
+running 278
+running 279
+running 280
+running 281
+running 282
+running 283
+running 284
+running 285
+running 286
+running 287
+running 288
+running 289
+running 290
+running 291
+running 292
+running 293
+running 294
+running 295
+running 296
+running 297
+running 298
+running 299
+running 300
+running 301
+running 302
+running 303
+running 304
+running 305
+running 306
+running 307
+running 308
+running 309
+running 310
+running 311
+running 312
+running 313
+running 314
+running 315
+running 316
+running 317
+running 318
+running 319
+running 320
+running 321
+running 322
+running 323
+running 324
+running 325
+running 326
+running 327
+running 328
+running 329
+running 330
+running 331
+running 332
+running 333
+running 334
+running 335
+running 336
+running 337
+running 338
+running 339
+running 340
+running 341
+running 342
+running 343
+running 344
+running 345
+running 346
+running 347
+running 348
+running 349
+running 350
+running 351
+running 352
+running 353
+running 354
+running 355
+running 356
+running 357
+running 358
+running 359
+running 360
+running 361
+running 362
+running 363
+running 364
+running 365
+running 366
+running 367
+running 368
+running 369
+running 370
+running 371
+running 372
+running 373
+running 374
+running 375
+running 376
+running 377
+running 378
+running 379
+running 380
+running 381
+running 382
+running 383
+running 384
+running 385
+running 386
+running 387
+running 388
+running 389
+running 390
+running 391
+running 392
+running 393
+running 394
+running 395
+running 396
+running 397
+running 398
+running 399
+running 400
+running 401
+running 402
+running 403
+running 404
+running 405
+running 406
+running 407
+running 408
+running 409
+running 410
+running 411
+running 412
+running 413
+running 414
+running 415
+running 416
+running 417
+running 418
+running 419
+running 420
+running 421
+running 422
+running 423
+running 424
+running 425
+running 426
+running 427
+running 428
+running 429
+running 430
+running 431
+running 432
+running 433
+running 434
+running 435
+running 436
+running 437
+running 438
+running 439
+running 440
+running 441
+running 442
+running 443
+running 444
+running 445
+running 446
+running 447
+running 448
+running 449
+running 450
+running 451
+running 452
+running 453
+running 454
+running 455
+running 456
+running 457
+running 458
+running 459
+running 460
+running 461
+running 462
+running 463
+running 464
+running 465
+running 466
+running 467
+running 468
+running 469
+running 470
+running 471
+running 472
+running 473
+running 474
+running 475
+running 476
+running 477
+running 478
+running 479
+running 480
+running 481
+running 482
+running 483
+running 484
+running 485
+running 486
+running 487
+running 488
+running 489
+running 490
+running 491
+running 492
+running 493
+running 494
+running 495
+running 496
+running 497
+running 498
+running 499
+running 500
+running 501
+running 502
+running 503
+running 504
+running 505
+running 506
+running 507
+running 508
+running 509
+running 510
+running 511
+Starting thread 'Thready'
+@ Thread running
+@ Got expected setDaemon exception
+@ Thread bailing
+Thread starter returning
+thread test done
diff --git a/test/051-thread/info.txt b/test/051-thread/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/051-thread/src/Main.java b/test/051-thread/src/Main.java
new file mode 100644 (file)
index 0000000..9acc89e
--- /dev/null
@@ -0,0 +1,73 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Test some basic thread stuff.
+ */
+public class Main {
+    public static void main(String[] args) {
+        for (int i = 0; i < 512; i++) {
+            MyThread myThread = new MyThread();
+            myThread.start();
+            try {
+                Thread.sleep(1);
+            } catch (InterruptedException ie) {
+                ie.printStackTrace();
+            }
+        }
+
+        go();
+        System.out.println("thread test done");
+    }
+
+    public static void go() {
+        Thread t = new Thread(null, new ThreadTestSub(), "Thready", 7168);
+
+        t.setDaemon(false);
+
+        System.out.print("Starting thread '" + t.getName() + "'\n");
+        t.start();
+
+        try {
+            t.join();
+        } catch (InterruptedException ex) {
+            ex.printStackTrace();
+        }
+
+        System.out.print("Thread starter returning\n");
+    }
+
+    /*
+     * Simple thread capacity test.
+     */
+    static class MyThread extends Thread {
+        private static int mCount = 0;
+        public void run() {
+            System.out.println("running " + (mCount++));
+        }
+    }
+}
+
+class ThreadTestSub implements Runnable {
+    public void run() {
+        System.out.print("@ Thread running\n");
+
+        try {
+            Thread.currentThread().setDaemon(true);
+            System.out.print("@ FAILED: setDaemon() succeeded\n");
+        } catch (IllegalThreadStateException itse) {
+            System.out.print("@ Got expected setDaemon exception\n");
+        }
+
+        //if (true)
+        //    throw new NullPointerException();
+        try {
+            Thread.sleep(2000);
+        }
+        catch (InterruptedException ie) {
+            System.out.print("@ Interrupted!\n");
+        }
+        finally {
+            System.out.print("@ Thread bailing\n");
+        }
+    }
+}
diff --git a/test/052-verifier-fun/expected.txt b/test/052-verifier-fun/expected.txt
new file mode 100644 (file)
index 0000000..5662675
--- /dev/null
@@ -0,0 +1,2 @@
+BlahOne
+Zorch.
diff --git a/test/052-verifier-fun/info.txt b/test/052-verifier-fun/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/052-verifier-fun/src/Blah.java b/test/052-verifier-fun/src/Blah.java
new file mode 100644 (file)
index 0000000..edd6c9d
--- /dev/null
@@ -0,0 +1,4 @@
+public abstract class Blah {
+    public void unrelatedStuff() {
+    }
+}
diff --git a/test/052-verifier-fun/src/BlahFeature.java b/test/052-verifier-fun/src/BlahFeature.java
new file mode 100644 (file)
index 0000000..ea0e18a
--- /dev/null
@@ -0,0 +1,3 @@
+public interface BlahFeature {
+    public void doStuff();
+}
diff --git a/test/052-verifier-fun/src/BlahOne.java b/test/052-verifier-fun/src/BlahOne.java
new file mode 100644 (file)
index 0000000..ed423cd
--- /dev/null
@@ -0,0 +1,5 @@
+public class BlahOne extends Blah implements BlahFeature {
+    public void doStuff() {
+        System.out.println("BlahOne");
+    }
+}
diff --git a/test/052-verifier-fun/src/BlahTwo.java b/test/052-verifier-fun/src/BlahTwo.java
new file mode 100644 (file)
index 0000000..cff3670
--- /dev/null
@@ -0,0 +1,5 @@
+public class BlahTwo extends Blah implements BlahFeature {
+    public void doStuff() {
+        System.out.println("BlahTwo");
+    }
+}
diff --git a/test/052-verifier-fun/src/Main.java b/test/052-verifier-fun/src/Main.java
new file mode 100644 (file)
index 0000000..ca960cf
--- /dev/null
@@ -0,0 +1,109 @@
+// Copyright 2007 The Android Open Source Project
+
+import java.lang.reflect.Type;
+
+/**
+ * Throw a few things at the verifier, all of which are expected to pass.
+ */
+public class Main {
+    static public void main(String[] args) {
+        tryBlah(1);
+
+        System.out.println("Zorch.");
+    }
+
+    /*
+     * Make sure the verifier is handling type merge of arrays of
+     * references correctly.
+     */
+    static Object[] arrayCheck1(int wanted) {
+        String[] arrayOne;
+        Integer[] arrayTwo;
+
+        arrayOne = new String[1];
+        arrayTwo = new Integer[1];
+
+        switch (wanted) {
+            case 0:     return arrayOne;
+            case 1:     return arrayTwo;
+            default:    return null;
+        }
+    }
+
+    static Object arrayCheck1b(int wanted) {
+        String[] arrayOne;
+        Integer[] arrayTwo;
+        int[] arrayThree;
+
+        arrayOne = new String[1];
+        arrayTwo = new Integer[1];
+        arrayThree = new int[1];
+
+        switch (wanted) {
+            case 0:     return arrayOne;
+            case 1:     return arrayTwo;
+            case 2:     return arrayThree;
+            default:    return null;
+        }
+    }
+
+    static Object[] arrayCheck2(int wanted) {
+        String[][] arrayOne;
+        String[][] arrayTwo;
+        Integer[][] arrayThree;
+
+        arrayOne = new String[1][];
+        arrayTwo = new String[1][];
+        arrayThree = new Integer[1][];
+
+        switch (wanted) {
+            case 0:     return arrayOne;
+            case 1:     return arrayTwo;
+            case 2:     return arrayThree;
+            default:    return null;
+        }
+    }
+
+    static Object[] arrayCheck3(int wanted) {
+        String[][] arrayTwo;
+        String[][][][] arrayFour;
+
+        arrayTwo = new String[1][];
+        arrayFour = new String[1][][][];
+
+        switch (wanted) {
+            case 0:     return arrayTwo;
+            case 1:     return arrayFour;
+            default:    return null;
+        }
+    }
+
+    /*
+     * Check return type merge.
+     */
+    private Type[] typeTest() {
+        if(this == null) {
+            return (Class<?>[])null;
+        }
+        return (Type[])null;
+    }
+
+
+    /*
+     * Exercise the blahs.
+     */
+    static void tryBlah(int num) {
+        BlahFeature feature = null;     // interface ref
+
+        switch (num) {
+            case 1:
+                feature = new BlahOne();
+                break;
+            default:
+                feature = new BlahTwo();
+                break;
+        }
+
+        feature.doStuff();
+    }
+}
diff --git a/test/053-wait-some/expected.txt b/test/053-wait-some/expected.txt
new file mode 100644 (file)
index 0000000..182892c
--- /dev/null
@@ -0,0 +1,7 @@
+Caught expected exception on neg arg
+Waiting for 200ms...
+Waiting for 500ms...
+Waiting for 1000ms...
+Waiting for 2000ms...
+Waiting for 3500ms...
+Waiting for 8000ms...
diff --git a/test/053-wait-some/info.txt b/test/053-wait-some/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/053-wait-some/src/Main.java b/test/053-wait-some/src/Main.java
new file mode 100644 (file)
index 0000000..51e6c52
--- /dev/null
@@ -0,0 +1,71 @@
+// Copyright 2007 The Android Open Source Project
+
+/**
+ * Exercise Object.wait(), comparing results against wall clock time.
+ */
+public class Main {
+    /* delays, in milliseconds */
+    private final static long[] DELAYS = {
+        200, 500, 1000, 2000, 3500, 8000
+    };
+
+    public static void main(String[] args) {
+        boolean timing = (args.length >= 1) && args[0].equals("--timing");
+        doit(timing);
+    }
+
+    public static void doit(boolean timing) {
+        Object sleepy = new Object();
+        long start, end;
+
+        synchronized (sleepy) {
+            try {
+                sleepy.wait(-500);
+                System.out.println("HEY: didn't throw on negative arg");
+            } catch (IllegalArgumentException iae) {
+                System.out.println("Caught expected exception on neg arg");
+            } catch (InterruptedException ie) {
+                ie.printStackTrace();
+            }
+
+            for(long delay : DELAYS) {
+                System.out.println("Waiting for " + delay + "ms...");
+
+                start = System.currentTimeMillis();
+                try {
+                    sleepy.wait(delay);
+                } catch (InterruptedException ie) {
+                    ie.printStackTrace();
+                }
+                end = System.currentTimeMillis();
+
+                long elapsed = end - start;
+                boolean showTime = timing;
+
+                if (! timing) {
+                    long epsilon = delay / 10;
+                    if (epsilon > 50) {
+                        epsilon = 50;
+                    }
+
+                    long min = delay - epsilon;
+                    long max = delay + epsilon;
+
+                    if (elapsed < min) {
+                        System.out.println("  Elapsed time was too short");
+                        showTime = true;
+                    } else if (elapsed > max) {
+                        System.out.println("  Elapsed time was too long: "
+                            + "elapsed=" + elapsed + " max=" + max);
+                        showTime = true;
+                    }
+                }
+
+                if (showTime) {
+                    System.out.println("  Wall clock elapsed "
+                            + elapsed + "ms");
+                }
+            }
+        }
+    }
+}
diff --git a/test/054-uncaught/expected.txt b/test/054-uncaught/expected.txt
new file mode 100644 (file)
index 0000000..e7473be
--- /dev/null
@@ -0,0 +1,21 @@
+Test 1
+Uncaught exception DEFAULT!
+java.lang.NullPointerException: Hi diddly-ho, neighborino.
+       at Main.catchTheUncaught(Main.java:49)
+       at Main$Helper.run(Main.java:60)
+Test 2
+Uncaught exception THREAD!
+java.lang.NullPointerException: Hi diddly-ho, neighborino.
+       at Main.catchTheUncaught(Main.java:49)
+       at Main$Helper.run(Main.java:60)
+Test 3
+Uncaught exception THREAD!
+java.lang.NullPointerException: Hi diddly-ho, neighborino.
+       at Main.catchTheUncaught(Main.java:49)
+       at Main$Helper.run(Main.java:60)
+Test 1
+Uncaught exception DEFAULT!
+java.lang.NullPointerException: Hi diddly-ho, neighborino.
+       at Main.catchTheUncaught(Main.java:49)
+       at Main.main(Main.java:12)
+       at dalvik.system.NativeStart.main(Native Method)
diff --git a/test/054-uncaught/info.txt b/test/054-uncaught/info.txt
new file mode 100644 (file)
index 0000000..08127da
--- /dev/null
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/test/054-uncaught/src/Main.java b/test/054-uncaught/src/Main.java
new file mode 100644 (file)
index 0000000..4ee6b05
--- /dev/null
@@ -0,0 +1,63 @@
+// Copyright 2006 The Android Open Source Project
+
+/**
+ * Test the uncaught exception handler.
+ */
+public class Main {
+    public static void main(String[] args) {
+        testThread(1);
+        testThread(2);
+        testThread(3);
+
+        catchTheUncaught(1);
+    }
+
+    private static void testThread(int which) {
+        Thread t = new Helper(which);
+        t.start();
+
+        try {
+            t.join();
+        } catch (InterruptedException ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    static void catchTheUncaught(int which) {
+        ThreadDeathHandler defHandler = new ThreadDeathHandler("DEFAULT");
+        ThreadDeathHandler threadHandler = new ThreadDeathHandler("THREAD");
+
+        System.out.println("Test " + which);
+        switch (which) {
+            case 1: {
+                Thread.setDefaultUncaughtExceptionHandler(defHandler);
+                break;
+            }
+            case 2: {
+                Thread.currentThread().setUncaughtExceptionHandler(
+                        threadHandler);
+                break;
+            }
+            case 3: {
+                Thread.setDefaultUncaughtExceptionHandler(defHandler);
+                Thread.currentThread().setUncaughtExceptionHandler(
+                        threadHandler);
+                break;
+            }
+        }
+
+        throw new NullPointerException("Hi diddly-ho, neighborino.");
+    }
+
+    private static class Helper extends Thread {
+        private int which;
+
+        public Helper(int which) {
+            this.which = which;
+        }
+
+        public void run() {
+            catchTheUncaught(which);
+        }
+    }
+}
diff --git a/test/054-uncaught/src/ThreadDeathHandler.java b/test/054-uncaught/src/ThreadDeathHandler.java
new file mode 100644 (file)
index 0000000..5ea61a5
--- /dev/null
@@ -0,0 +1,19 @@
+// Copyright 2007 The Android Open Source Project
+
+import java.lang.Thread.UncaughtExceptionHandler;
+
+/**
+ * Report death-by-uncaught-exception.
+ */
+public class ThreadDeathHandler implements Thread.UncaughtExceptionHandler {
+    private String mMyMessage;
+
+    public ThreadDeathHandler(String msg) {
+        mMyMessage = msg;
+    }
+
+    public void uncaughtException(Thread t, Throwable e) {
+        System.err.println("Uncaught exception " + mMyMessage + "!");
+        e.printStackTrace();
+    }
+}
diff --git a/test/055-enum-performance/expected.txt b/test/055-enum-performance/expected.txt
new file mode 100644 (file)
index 0000000..ceb6bc4
--- /dev/null
@@ -0,0 +1,12 @@
+FOUR
+ONE
+FOURTEEN
+NINE
+FIVE
+TWELVE
+SamePackagePublicEnum
+basis: performed 10000 iterations
+test1: performed 10000 iterations
+test2: performed 10000 iterations
+test3: performed 10000 iterations
+Timing is acceptable.
diff --git a/test/055-enum-performance/info.txt b/test/055-enum-performance/info.txt
new file mode 100644 (file)
index 0000000..2ea1b9d
--- /dev/null
@@ -0,0 +1,2 @@
+This is a performance test of Enum.valueOf(). To see the numbers, invoke
+this test with the "--timing" option.
diff --git a/test/055-enum-performance/src/Main.java b/test/055-enum-performance/src/Main.java
new file mode 100644 (file)
index 0000000..43f45f1
--- /dev/null
@@ -0,0 +1,195 @@
+import otherpackage.OtherPackagePublicEnum;
+
+public class Main {
+    /** used by {@link #basisCall} */
+    static private int basisTestValue = 12;
+
+    static public void main(String[] args) throws Exception {
+        boolean timing = (args.length >= 1) && args[0].equals("--timing");
+        run(timing);
+    }
+
+    static public void run(boolean timing) {
+        preTest();
+
+        long time0 = System.nanoTime();
+        int count1 = test1(500);
+        long time1 = System.nanoTime();
+        int count2 = test2(500);
+        long time2 = System.nanoTime();
+        int count3 = test3(500);
+        long time3 = System.nanoTime();
+        int count4 = basis(500);
+        long time4 = System.nanoTime();
+
+        System.out.println("basis: performed " + count4 + " iterations");
+        System.out.println("test1: performed " + count1 + " iterations");
+        System.out.println("test2: performed " + count2 + " iterations");
+        System.out.println("test3: performed " + count3 + " iterations");
+
+        double msec1 = (time1 - time0) / (double) count1 / 1000000;
+        double msec2 = (time2 - time1) / (double) count2 / 1000000;
+        double msec3 = (time3 - time2) / (double) count3 / 1000000;
+        double basisMsec = (time4 - time3) / (double) count4 / 1000000;
+
+        double avg = (msec1 + msec2 + msec3) / 3;
+        if (avg < (basisMsec * 10)) {
+            System.out.println("Timing is acceptable.");
+        } else {
+            System.out.println("Iterations are taking too long!");
+            timing = true;
+        }
+
+        if (timing) {
+            System.out.printf("basis time: %.3g msec\n", basisMsec);
+            System.out.printf("test1: %.3g msec per iteration\n", msec1);
+            System.out.printf("test2: %.3g msec per iteration\n", msec2);
+            System.out.printf("test3: %.3g msec per iteration\n", msec3);
+        }
+
+    }
+
+    static public void preTest() {
+        /*
+         * This is meant to ensure that the basic enum functionality
+         * really is working.
+         */
+
+        Class<SamePackagePublicEnum> c = SamePackagePublicEnum.class;
+
+        System.out.println(Enum.valueOf(c, "FOUR"));
+        System.out.println(Enum.valueOf(c, "ONE"));
+        System.out.println(Enum.valueOf(c, "FOURTEEN"));
+        System.out.println(Enum.valueOf(c, "NINE"));
+        System.out.println(Enum.valueOf(c, "FIVE"));
+        System.out.println(Enum.valueOf(c, "TWELVE"));
+
+        System.out.println(Enum.valueOf(c, "ZERO").getClass().getName());
+    }
+
+    static final String[] BASIS_COMPARE_ARRAY = {
+        "ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT",
+        "NINE", "TEN", "ELEVEN", "TWELVE", "THIRTEEN", "FOURTEEN", "FIFTEEN",
+        "SIXTEEN", "SEVENTEEN", "EIGHTEEN", "NINETEEN"
+    };
+
+    static public int basis(int iters) {
+        for (int i = iters; i > 0; i--) {
+            basisValueOf("ZERO");
+            basisValueOf("ONE");
+            basisValueOf("TWO");
+            basisValueOf("THREE");
+            basisValueOf("FOUR");
+            basisValueOf("FIVE");
+            basisValueOf("SIX");
+            basisValueOf("SEVEN");
+            basisValueOf("EIGHT");
+            basisValueOf("NINE");
+            basisValueOf("TEN");
+            basisValueOf("ELEVEN");
+            basisValueOf("TWELVE");
+            basisValueOf("THIRTEEN");
+            basisValueOf("FOURTEEN");
+            basisValueOf("FIFTEEN");
+            basisValueOf("SIXTEEN");
+            basisValueOf("SEVENTEEN");
+            basisValueOf("EIGHTEEN");
+            basisValueOf("NINETEEN");
+        }
+
+        return iters * 20;
+    }
+
+    static String basisValueOf(String key) {
+        for (String s : BASIS_COMPARE_ARRAY) {
+            if (s.equals(key)) {
+                return s;
+            }
+        }
+        throw new IllegalArgumentException();
+    }
+
+    static public int test1(int iters) {
+        Class<SamePackagePublicEnum> c = SamePackagePublicEnum.class;
+        for (int i = iters; i > 0; i--) {
+            Enum.valueOf(c, "ZERO");
+            Enum.valueOf(c, "ONE");
+            Enum.valueOf(c, "TWO");
+            Enum.valueOf(c, "THREE");
+            Enum.valueOf(c, "FOUR");
+            Enum.valueOf(c, "FIVE");
+            Enum.valueOf(c, "SIX");
+            Enum.valueOf(c, "SEVEN");
+            Enum.valueOf(c, "EIGHT");
+            Enum.valueOf(c, "NINE");
+            Enum.valueOf(c, "TEN");
+            Enum.valueOf(c, "ELEVEN");
+            Enum.valueOf(c, "TWELVE");
+            Enum.valueOf(c, "THIRTEEN");
+            Enum.valueOf(c, "FOURTEEN");
+            Enum.valueOf(c, "FIFTEEN");
+            Enum.valueOf(c, "SIXTEEN");
+            Enum.valueOf(c, "SEVENTEEN");
+            Enum.valueOf(c, "EIGHTEEN");
+            Enum.valueOf(c, "NINETEEN");
+        }
+
+        return iters * 20;
+    }
+
+    static public int test2(int iters) {
+        Class<SamePackagePrivateEnum> c = SamePackagePrivateEnum.class;
+        for (int i = iters; i > 0; i--) {
+            Enum.valueOf(c, "ZERO");
+            Enum.valueOf(c, "ONE");
+            Enum.valueOf(c, "TWO");
+            Enum.valueOf(c, "THREE");
+            Enum.valueOf(c, "FOUR");
+            Enum.valueOf(c, "FIVE");
+            Enum.valueOf(c, "SIX");
+            Enum.valueOf(c, "SEVEN");
+            Enum.valueOf(c, "EIGHT");
+            Enum.valueOf(c, "NINE");
+            Enum.valueOf(c, "TEN");
+            Enum.valueOf(c, "ELEVEN");
+            Enum.valueOf(c, "TWELVE");
+            Enum.valueOf(c, "THIRTEEN");
+            Enum.valueOf(c, "FOURTEEN");
+            Enum.valueOf(c, "FIFTEEN");
+            Enum.valueOf(c, "SIXTEEN");
+            Enum.valueOf(c, "SEVENTEEN");
+            Enum.valueOf(c, "EIGHTEEN");
+            Enum.valueOf(c, "NINETEEN");
+        }
+
+        return iters * 20;
+    }
+
+    static public int test3(int iters) {
+        Class<OtherPackagePublicEnum> c = OtherPackagePublicEnum.class;
+        for (int i = iters; i > 0; i--) {
+            Enum.valueOf(c, "ZERO");
+            Enum.valueOf(c, "ONE");
+            Enum.valueOf(c, "TWO");
+            Enum.valueOf(c, "THREE");
+            Enum.valueOf(c, "FOUR");
+            Enum.valueOf(c, "FIVE");
+            Enum.valueOf(c, "SIX");
+            Enum.valueOf(c, "SEVEN");
+            Enum.valueOf(c, "EIGHT");
+            Enum.valueOf(c, "NINE");
+            Enum.valueOf(c, "TEN");
+            Enum.valueOf(c, "ELEVEN");
+            Enum.valueOf(c, "TWELVE");
+            Enum.valueOf(c, "THIRTEEN");
+            Enum.valueOf(c, "FOURTEEN");
+            Enum.valueOf(c, "FIFTEEN");
+            Enum.valueOf(c, "SIXTEEN");
+            Enum.valueOf(c, "SEVENTEEN");
+            Enum.valueOf(c, "EIGHTEEN");
+            Enum.valueOf(c, "NINETEEN");
+        }
+
+        return iters * 20;
+    }
+}
diff --git a/test/055-enum-performance/src/SamePackagePrivateEnum.java b/test/055-enum-performance/src/SamePackagePrivateEnum.java
new file mode 100644 (file)
index 0000000..b6759f6
--- /dev/null
@@ -0,0 +1,5 @@
+/*package*/ enum SamePackagePrivateEnum {
+    ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE,
+        TEN, ELEVEN, TWELVE, THIRTEEN, FOURTEEN, FIFTEEN, SIXTEEN,
+        SEVENTEEN, EIGHTEEN, NINETEEN;
+}
diff --git a/test/055-enum-performance/src/SamePackagePublicEnum.java b/test/055-enum-performance/src/SamePackagePublicEnum.java
new file mode 100644 (file)
index 0000000..3a1c230
--- /dev/null
@@ -0,0 +1,5 @@
+public enum SamePackagePublicEnum {
+    ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE,
+        TEN, ELEVEN, TWELVE, THIRTEEN, FOURTEEN, FIFTEEN, SIXTEEN,
+        SEVENTEEN, EIGHTEEN, NINETEEN;
+}
diff --git a/test/055-enum-performance/src/otherpackage/OtherPackagePublicEnum.java b/test/055-enum-performance/src/otherpackage/OtherPackagePublicEnum.java
new file mode 100644 (file)
index 0000000..4ef4d78
--- /dev/null
@@ -0,0 +1,7 @@
+package otherpackage;
+
+public enum OtherPackagePublicEnum {
+    ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE,
+        TEN, ELEVEN, TWELVE, THIRTEEN, FOURTEEN, FIFTEEN, SIXTEEN,
+        SEVENTEEN, EIGHTEEN, NINETEEN;
+}
diff --git a/test/056-const-string-jumbo/build b/test/056-const-string-jumbo/build
new file mode 100644 (file)
index 0000000..c5e35db
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/bash
+#
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# 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.
+
+# Stop if something fails.
+set -e
+
+# Write out files with 32768 total static string declarations, so that
+# the reference to "zorch" in the real test file will be guaranteed to
+# need a jumbo string reference (it sorts last after all the others).
+# Note: Each string reference is stored in a separate static variable,
+# and that variable's name is also represented in the strings, which
+# is why we can just have 32768 and not 65536 declarations.
+
+awk '
+BEGIN {
+    writeFile("Zorch1", 0, 16383);
+    writeFile("Zorch2", 16384, 32767);
+}
+function writeFile(name, start, end) {
+    fileName = "src/" name ".java";
+    printf("public class %s {\n", name) > fileName;
+    for (i = start; i <= end; i++) {
+        printf("    static public final String s%d = \"%d\";\n",
+            i, i) > fileName;
+    }
+    printf("}\n") > fileName;
+}'
+
+mkdir classes
+${JAVAC} -d classes src/*.java
+
+dx -JXmx500m --debug --dex --no-optimize --positions=none --no-locals \
+    --dump-to=classes.lst --output=classes.dex classes
+zip test.jar classes.dex
diff --git a/test/056-const-string-jumbo/expected.txt b/test/056-const-string-jumbo/expected.txt
new file mode 100644 (file)
index 0000000..bebbf9e
--- /dev/null
@@ -0,0 +1 @@
+zorch
diff --git a/test/056-const-string-jumbo/info.txt b/test/056-const-string-jumbo/info.txt
new file mode 100644 (file)
index 0000000..c4ba856
--- /dev/null
@@ -0,0 +1 @@
+Test that the opcode const-string/jumbo works.
diff --git a/test/056-const-string-jumbo/src/Main.java b/test/056-const-string-jumbo/src/Main.java
new file mode 100644 (file)
index 0000000..68d6e53
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+public class Main {
+    static public void main(String[] args) {
+        System.out.println("zorch");
+    }
+}
diff --git a/test/058-enum-order/expected.txt b/test/058-enum-order/expected.txt
new file mode 100644 (file)
index 0000000..b812404
--- /dev/null
@@ -0,0 +1,5 @@
+0: CORN
+1: BLUEBERRY
+2: CRANBERRY
+3: BRAN
+4: BLACKBERRY
diff --git a/test/058-enum-order/info.txt b/test/058-enum-order/info.txt
new file mode 100644 (file)
index 0000000..b9809fd
--- /dev/null
@@ -0,0 +1 @@
+Test that the ordering of enums is as expected.
diff --git a/test/058-enum-order/src/Main.java b/test/058-enum-order/src/Main.java
new file mode 100644 (file)
index 0000000..2cd6052
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/**
+ * Test enum ordering.
+ */
+public class Main {
+    public static enum Muffin {
+        CORN, BLUEBERRY, CRANBERRY, BRAN, BLACKBERRY;
+    }
+
+    public static void main(String args[]) {
+        Muffin[] array = Muffin.class.getEnumConstants();
+        for (Muffin m : array) {
+            System.out.println(m.ordinal() + ": " + m);
+        }
+    }
+}
diff --git a/test/059-finalizer-throw/expected.txt b/test/059-finalizer-throw/expected.txt
new file mode 100644 (file)
index 0000000..cbc9ece
--- /dev/null
@@ -0,0 +1,2 @@
+In finalizer
+done
diff --git a/test/059-finalizer-throw/info.txt b/test/059-finalizer-throw/info.txt
new file mode 100644 (file)
index 0000000..6261372
--- /dev/null
@@ -0,0 +1 @@
+Verify that exceptions thrown from finalizers are ignored.
diff --git a/test/059-finalizer-throw/src/Main.java b/test/059-finalizer-throw/src/Main.java
new file mode 100644 (file)
index 0000000..42260e4
--- /dev/null
@@ -0,0 +1,56 @@
+// Copyright 2008 The Android Open Source Project
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+/*
+ * Throw an exception from a finalizer and make sure it's harmless.  Under
+ * Dalvik this may also generate a warning in the log file.
+ */
+public class Main {
+    static Object waiter = new Object();
+    static volatile boolean didFinal = false;
+
+    static void createAndForget() {
+        Main main = new Main();
+    }
+
+    public static void main(String[] args) {
+        createAndForget();
+
+        System.gc();
+        System.runFinalization();
+
+        new Timer(true).schedule(new TimerTask() {
+                public void run() {
+                    System.out.println("Timed out, exiting");
+                    System.exit(1);
+                }
+            }, 30000);
+
+        while (!didFinal) {
+            try {
+                Thread.sleep(500);
+            } catch (InterruptedException ie) {
+                System.err.println(ie);
+            }
+        }
+
+        /* give it a chance to cause mayhem */
+        try {
+            Thread.sleep(750);
+        } catch (InterruptedException ie) {
+            System.err.println(ie);
+        }
+
+        System.out.println("done");
+    }
+
+    protected void finalize() throws Throwable {
+        System.out.println("In finalizer");
+
+        didFinal = true;
+
+        throw new InterruptedException("whee");
+    }
+}
diff --git a/test/061-out-of-memory/expected.txt b/test/061-out-of-memory/expected.txt
new file mode 100644 (file)
index 0000000..ca87629
--- /dev/null
@@ -0,0 +1,7 @@
+tests beginning
+Got expected huge-array OOM
+testOomeLarge beginning
+testOomeLarge succeeded
+testOomeSmall beginning
+testOomeSmall succeeded
+tests succeeded
diff --git a/test/061-out-of-memory/info.txt b/test/061-out-of-memory/info.txt
new file mode 100644 (file)
index 0000000..523f3a2
--- /dev/null
@@ -0,0 +1 @@
+Tests the various ways that an OutOfMemoryError can be constructed and thrown.
diff --git a/test/061-out-of-memory/src/Main.java b/test/061-out-of-memory/src/Main.java
new file mode 100644 (file)
index 0000000..b5999b3
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+import java.util.Arrays;
+import java.util.LinkedList;
+
+/**
+ * Exercise the construction and throwing of OutOfMemoryError.
+ */
+public class Main {
+    public static void main(String args[]) {
+        System.out.println("tests beginning");
+        testHugeArray();
+        testOomeLarge();
+        testOomeSmall();
+        System.out.println("tests succeeded");
+    }
+
+    private static void testHugeArray() {
+        try {
+            final int COUNT = 32768*32768 + 4;
+            int[] tooBig = new int[COUNT];
+
+            Arrays.fill(tooBig, 0xdd);
+        } catch (OutOfMemoryError oom) {
+            System.out.println("Got expected huge-array OOM");
+        }
+    }
+
+    private static void testOomeLarge() {
+        System.out.println("testOomeLarge beginning");
+
+        /* Just shy of the typical max heap size so that it will actually
+         * try to allocate it instead of short-circuiting.
+         *
+         * TODO: stop assuming the VM defaults to 16MB max
+         */
+        final int SIXTEEN_MB = (16 * 1024 * 1024 - 32);
+
+        Boolean sawEx = false;
+        byte a[];
+
+        try {
+            a = new byte[SIXTEEN_MB];
+        } catch (OutOfMemoryError oom) {
+            //Log.i(TAG, "HeapTest/OomeLarge caught " + oom);
+            sawEx = true;
+        }
+
+        if (!sawEx) {
+            throw new RuntimeException("Test failed: " +
+                    "OutOfMemoryError not thrown");
+        }
+
+        System.out.println("testOomeLarge succeeded");
+    }
+
+    /* Do this in another method so that the GC has a chance of freeing the
+     * list afterwards.  Even if we null out list when we're done, the conservative
+     * GC may see a stale pointer to it in a register.
+     *
+     * TODO: stop assuming the VM defaults to 16MB max
+     */
+    private static boolean testOomeSmallInternal() {
+        final int SIXTEEN_MB = (16 * 1024 * 1024);
+        final int LINK_SIZE = 6 * 4; // estimated size of a LinkedList's node
+
+        LinkedList<Object> list = new LinkedList<Object>();
+
+        /* Allocate progressively smaller objects to fill up the entire heap.
+         */
+        int objSize = 1 * 1024 * 1024;
+        while (objSize >= LINK_SIZE) {
+            boolean sawEx = false;
+            try {
+                for (int i = 0; i < SIXTEEN_MB / objSize; i++) {
+                    list.add((Object)new byte[objSize]);
+                }
+            } catch (OutOfMemoryError oom) {
+                sawEx = true;
+            }
+
+            if (!sawEx) {
+                return false;
+            }
+
+            objSize = (objSize * 4) / 5;
+        }
+
+        return true;
+    }
+
+    private static void testOomeSmall() {
+        System.out.println("testOomeSmall beginning");
+        if (!testOomeSmallInternal()) {
+            /* Can't reliably throw this from inside the internal function, because
+             * we may not be able to allocate the RuntimeException.
+             */
+            throw new RuntimeException("Test failed: " +
+                    "OutOfMemoryError not thrown while filling heap");
+        }
+        System.out.println("testOomeSmall succeeded");
+    }
+}
diff --git a/test/062-character-encodings/expected.txt b/test/062-character-encodings/expected.txt
new file mode 100644 (file)
index 0000000..b395a2a
--- /dev/null
@@ -0,0 +1 @@
+Missing: []
diff --git a/test/062-character-encodings/info.txt b/test/062-character-encodings/info.txt
new file mode 100644 (file)
index 0000000..bdf60bf
--- /dev/null
@@ -0,0 +1 @@
+Test that the list of character encodings is what we expect.
diff --git a/test/062-character-encodings/src/Main.java b/test/062-character-encodings/src/Main.java
new file mode 100644 (file)
index 0000000..6e9f0cd
--- /dev/null
@@ -0,0 +1,25 @@
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.Set;
+
+public class Main {
+    static public void main(String[] args) throws Exception {
+        // These charsets must be provided; anything else is optional.
+        List<String> standardCharsets = Arrays.asList("US-ASCII", "ISO-8859-1",
+                "UTF-8", "UTF-16BE", "UTF-16LE", "UTF-16");
+
+        SortedMap<String, Charset> all = Charset.availableCharsets();
+        Set<String> needed = new HashSet<String>(standardCharsets);
+        for (Map.Entry<String, Charset> e : all.entrySet()) {
+            String canonicalName = e.getKey();
+            needed.remove(canonicalName);
+        }
+        System.out.println("Missing: " + needed);
+    }
+}
diff --git a/test/063-process-manager/expected.txt b/test/063-process-manager/expected.txt
new file mode 100644 (file)
index 0000000..8360239
--- /dev/null
@@ -0,0 +1,15 @@
+process manager: nonexistent
+
+spawning child #1
+spawning child
+process manager: RUNNABLE
+child died
+process manager: WAITING
+
+spawning child #2
+spawning child
+process manager: RUNNABLE
+child died
+process manager: WAITING
+
+done!
diff --git a/test/063-process-manager/info.txt b/test/063-process-manager/info.txt
new file mode 100644 (file)
index 0000000..e5907c4
--- /dev/null
@@ -0,0 +1,2 @@
+Test that spawning a child process and then reaping it (a) works and (b)
+doesn't cause the system to busy-wait.
diff --git a/test/063-process-manager/src/Main.java b/test/063-process-manager/src/Main.java
new file mode 100644 (file)
index 0000000..c94b8ad
--- /dev/null
@@ -0,0 +1,43 @@
+import java.util.Map;
+
+public class Main {
+    static public void main(String[] args) throws Exception {
+        checkManager();
+        for (int i = 1; i <= 2; i++) {
+            System.out.println("\nspawning child #" + i);
+            child();
+            Thread.sleep(2000);
+            checkManager();
+        }
+        System.out.println("\ndone!");
+    }
+
+    static private void child() throws Exception {
+        System.out.println("spawning child");
+        ProcessBuilder pb = new ProcessBuilder("/system/bin/sleep", "5");
+        Process proc = pb.start();
+        Thread.sleep(1000);
+        checkManager();
+        proc.waitFor();
+        System.out.println("child died");
+    }
+
+    static private void checkManager() {
+        Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
+        boolean found = false;
+
+        for (Map.Entry<Thread, StackTraceElement[]> entry :
+                 traces.entrySet()) {
+            Thread t = entry.getKey();
+            String name = t.getName();
+            if (name.equals("java.lang.ProcessManager")) {
+                System.out.println("process manager: " + t.getState());
+                found = true;
+            }
+        }
+
+        if (! found) {
+            System.out.println("process manager: nonexistent");
+        }
+    }
+}
diff --git a/test/064-field-access/expected.txt b/test/064-field-access/expected.txt
new file mode 100644 (file)
index 0000000..0af56ba
--- /dev/null
@@ -0,0 +1,2 @@
+good
+Got expected failure
diff --git a/test/064-field-access/info.txt b/test/064-field-access/info.txt
new file mode 100644 (file)
index 0000000..442baf2
--- /dev/null
@@ -0,0 +1,10 @@
+The documentation lists exceptional conditions and the exceptions that
+should be thrown, but doesn't say which exception previals when two or
+more exceptional conditions exist at the same time.  For example,
+attempting to set a protected field from an unrelated class causes an
+IllegalAccessException, while passing in a data type that doesn't match
+the field causes an IllegalArgumentException.  If code does both at the
+same time, we can only throw one or the other.
+
+This exercises the various failure modes to ensure that behavior is
+equivalent, and not merely spec-compliant.
diff --git a/test/064-field-access/src/GetNonexistent.java b/test/064-field-access/src/GetNonexistent.java
new file mode 100644 (file)
index 0000000..faad686
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class GetNonexistent {
+    public static void main(String[] args) {
+        Object obj = Holder.mObject;
+    }
+}
diff --git a/test/064-field-access/src/Holder.java b/test/064-field-access/src/Holder.java
new file mode 100644 (file)
index 0000000..5e34024
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Holder {
+    public static Object mObject = new Object();
+}
diff --git a/test/064-field-access/src/Main.java b/test/064-field-access/src/Main.java
new file mode 100644 (file)
index 0000000..c068d23
--- /dev/null
@@ -0,0 +1,345 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+import other.OtherPackage;
+
+import java.lang.reflect.Field;
+
+/*
+ * Test field access through reflection.
+ */
+public class Main {
+    public static void main(String[] args) {
+        SubOther.main(null);
+
+        try {
+            GetNonexistent.main(null);
+            System.err.println("Not expected to succeed");
+        } catch (VerifyError fe) {
+            // dalvik
+            System.out.println("Got expected failure");
+        } catch (NoSuchFieldError nsfe) {
+            // reference
+            System.out.println("Got expected failure");
+        }
+    }
+
+    /*
+     * Get the field specified by "field" from "obj".
+     *
+     * "type" determines which "get" call is made, e.g. 'B' turns into
+     * field.getByte().
+     *
+     * The "expectedException" must match the class of the exception thrown,
+     * or be null if no exception was expected.
+     *
+     * On success, the boxed value retrieved is returned.
+     */
+    public Object getValue(Field field, Object obj, char type,
+            Class expectedException) {
+
+        Object result = null;
+        try {
+            switch (type) {
+            case 'Z':
+                result = new Boolean(field.getBoolean(obj));
+                break;
+            case 'B':
+                result = new Byte(field.getByte(obj));
+                break;
+            case 'S':
+                result = new Short(field.getShort(obj));
+                break;
+            case 'C':
+                result = new Character(field.getChar(obj));
+                break;
+            case 'I':
+                result = new Integer(field.getInt(obj));
+                break;
+            case 'J':
+                result = new Long(field.getLong(obj));
+                break;
+            case 'F':
+                result = new Float(field.getFloat(obj));
+                break;
+            case 'D':
+                result = new Double(field.getDouble(obj));
+                break;
+            case 'L':
+                result = field.get(obj);
+                break;
+            default:
+                throw new RuntimeException("bad type '" + type + "'");
+            }
+
+            /* success; expected? */
+            if (expectedException != null) {
+                Throwable th = new Throwable();
+                System.err.println("ERROR: call succeeded, was expecting "
+                    + expectedException);
+                th.printStackTrace();
+            }
+        } catch (Exception ex) {
+            if (expectedException == null) {
+                System.err.println("ERROR: call failed unexpectedly: "
+                    + ex.getClass());
+                ex.printStackTrace();
+            } else {
+                if (!expectedException.equals(ex.getClass())) {
+                    System.err.println("ERROR: incorrect exception: wanted "
+                        + expectedException.getName() + ", got "
+                        + ex.getClass());
+                    ex.printStackTrace();
+                }
+            }
+        }
+
+        return result;
+    }
+}
+
+/*
+ * Local class with some fields.
+ */
+class SamePackage {
+    public byte pubByteField;
+
+    protected byte protByteField;
+    protected Object protObjectField;
+
+    private float privFloatField;
+}
+
+/*
+ * This is a sub-class of OtherPackage, which should be allowed to access
+ * the various protected fields.
+ */
+class SubOther extends OtherPackage {
+
+    protected long protLongField = 0x1122334455667788L;
+
+    /*
+     * Perform the various tests.
+     *
+     * localInst.getValue() is performed using an instance of Main as the
+     * source of the reflection call.  otherInst.getValue() uses a subclass
+     * of OtherPackage as the source.
+     */
+    public static void main(String[] args) {
+        SubOther subOther = new SubOther();
+        subOther.doTests();
+    }
+
+    public void doTests() {
+        Class localClass = SamePackage.class;
+        Class otherClass = OtherPackage.class;
+        Field localPubByteField, localProtByteField, localProtObjectField,
+              localPrivFloatField;
+        Field otherPubCharField, otherProtShortField, otherProtObjectField,
+              otherPkgDoubleField;
+        Field subProtLongField;
+        Main localInst = new Main();
+        SamePackage samePkgInst = new SamePackage();
+        OtherPackage otherPkgInst = new OtherPackage();
+        Object plainObj = new Object();
+
+        /*
+         * Locate the various fields.
+         */
+        try {
+            localPubByteField = localClass.getDeclaredField("pubByteField");
+            localProtByteField = localClass.getDeclaredField("protByteField");
+            localProtObjectField = localClass.getDeclaredField("protObjectField");
+            localPrivFloatField = localClass.getDeclaredField("privFloatField");
+
+            otherPubCharField = otherClass.getDeclaredField("pubCharField");
+            otherProtShortField = otherClass.getDeclaredField("protShortField");
+            otherProtObjectField = otherClass.getDeclaredField("protObjectField");
+            otherPkgDoubleField = otherClass.getDeclaredField("pkgDoubleField");
+
+            subProtLongField = getClass().getDeclaredField("protLongField");
+        } catch (NoSuchFieldException nsfe) {
+            throw new RuntimeException(nsfe);
+        }
+
+        /*
+         * Get a public field from a class in the same package.
+         */
+        localInst.getValue(localPubByteField, samePkgInst, 'B', null);
+
+        /*
+         * Get a protected field from a class in the same package.
+         */
+        this.getValue(localProtByteField, samePkgInst, 'B', null);
+
+        /*
+         * Get a private field from a class in the same package.
+         */
+        this.getValue(localPrivFloatField, samePkgInst, 'F',
+            IllegalAccessException.class);
+
+        /*
+         * Get a protected field from otherInst's superclass.
+         *
+         * We can get at "this.protShortField" but not
+         * "otherPkgInst.protShortField" because we can only access
+         * protected fields in instances of our class -- being a subclass
+         * of OtherPackage does not allow us to modify protected fields in
+         * all other subclasses of OtherPackage.
+         */
+        this.getValue(otherProtShortField, this, 'S',
+            null);
+        this.getValue(otherProtShortField, otherPkgInst, 'S',
+            IllegalAccessException.class);
+        this.getValue(otherPkgDoubleField, otherPkgInst, 'D',
+            IllegalAccessException.class);
+
+        /*
+         * Null object.  Different exceptions based on which package
+         * we would be trying to access and whether or not our object
+         * has the correct type.
+         */
+        localInst.getValue(localPubByteField, null, 'B',
+            NullPointerException.class);
+
+        this.getValue(subProtLongField, null, 'J',
+            NullPointerException.class);
+
+        this.getValue(localPrivFloatField, null, 'F',
+            IllegalAccessException.class);
+
+        localInst.getValue(otherProtShortField, null, 'S',
+            IllegalAccessException.class);
+        this.getValue(otherProtShortField, null, 'S',
+            IllegalAccessException.class);
+        this.getValue(otherPkgDoubleField, null, 'D',
+            IllegalAccessException.class);
+
+        localInst.getValue(otherProtShortField, null, 'Z',
+            IllegalAccessException.class);
+        /* -- Dalvik VM currently throws NPE
+        this.getValue(subProtLongField, null, 'Z',
+            IllegalArgumentException.class);
+        */
+
+        /*
+         * Valid object, wrong field type.
+         */
+        this.getValue(subProtLongField, this, 'J',
+            null);
+        this.getValue(localProtByteField, samePkgInst, 'Z',
+            IllegalArgumentException.class);
+        this.getValue(subProtLongField, this, 'Z',
+            IllegalArgumentException.class);
+        this.getValue(localPrivFloatField, this, 'Z',
+            IllegalAccessException.class);
+        this.getValue(localPrivFloatField, this, 'Z',
+            IllegalAccessException.class);
+        localInst.getValue(otherProtShortField, otherPkgInst, 'Z',
+            IllegalAccessException.class);
+        this.getValue(otherProtShortField, otherPkgInst, 'Z',
+            IllegalAccessException.class);
+
+        /*
+         * Wrong object.
+         */
+        this.getValue(subProtLongField, plainObj, 'J',
+            IllegalArgumentException.class);
+
+        /* wrong object + private field */
+        this.getValue(localPrivFloatField, plainObj, 'F',
+            IllegalAccessException.class);
+
+        /* wrong object + wrong field type */
+        this.getValue(subProtLongField, plainObj, 'Z',
+            IllegalArgumentException.class);
+
+        /* wrong object + invalid access */
+        localInst.getValue(otherProtShortField, plainObj, 'S',
+            IllegalAccessException.class);
+        this.getValue(otherProtShortField, plainObj, 'S',
+            IllegalAccessException.class);
+
+        System.out.println("good");
+    }
+
+    /*
+     * [this is a clone of Main.getValue() -- the class issuing the
+     * reflection call is significant]
+     */
+    public Object getValue(Field field, Object obj, char type,
+            Class expectedException) {
+
+        Object result = null;
+        try {
+            switch (type) {
+            case 'Z':
+                result = new Boolean(field.getBoolean(obj));
+                break;
+            case 'B':
+                result = new Byte(field.getByte(obj));
+                break;
+            case 'S':
+                result = new Short(field.getShort(obj));
+                break;
+            case 'C':
+                result = new Character(field.getChar(obj));
+                break;
+            case 'I':
+                result = new Integer(field.getInt(obj));
+                break;
+            case 'J':
+                result = new Long(field.getLong(obj));
+                break;
+            case 'F':
+                result = new Float(field.getFloat(obj));
+                break;
+            case 'D':
+                result = new Double(field.getDouble(obj));
+                break;
+            case 'L':
+                result = field.get(obj);
+                break;
+            default:
+                throw new RuntimeException("bad type '" + type + "'");
+            }
+
+            /* success; expected? */
+            if (expectedException != null) {
+                Throwable th = new Throwable();
+                System.err.println("ERROR: call succeeded, was expecting "
+                    + expectedException);
+                th.printStackTrace();
+            }
+        } catch (Exception ex) {
+            if (expectedException == null) {
+                System.err.println("ERROR: call failed unexpectedly: "
+                    + ex.getClass());
+                ex.printStackTrace();
+            } else {
+                if (!expectedException.equals(ex.getClass())) {
+                    System.err.println("ERROR: incorrect exception: wanted "
+                        + expectedException.getName() + ", got "
+                        + ex.getClass());
+                    ex.printStackTrace();
+                }
+            }
+        }
+
+        return result;
+    }
+
+}
diff --git a/test/064-field-access/src/other/OtherPackage.java b/test/064-field-access/src/other/OtherPackage.java
new file mode 100644 (file)
index 0000000..a595db5
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2008 The Android Open Source Project
+
+package other;
+
+/*
+ * Declare a few fields to reflect upon.
+ */
+public class OtherPackage {
+    public char pubCharField = 0x8765;
+
+    protected short protShortField = 0x1234;
+    protected Object protObjectField = "blah";
+
+    double pkgDoubleField = 3.141592654;
+}
diff --git a/test/064-field-access/src2/Holder.java b/test/064-field-access/src2/Holder.java
new file mode 100644 (file)
index 0000000..28224d7
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Holder {
+    //public static Object mObject = new Object();
+}
diff --git a/test/065-mismatched-implements/expected.txt b/test/065-mismatched-implements/expected.txt
new file mode 100644 (file)
index 0000000..09c0596
--- /dev/null
@@ -0,0 +1 @@
+Got expected ICCE
diff --git a/test/065-mismatched-implements/info.txt b/test/065-mismatched-implements/info.txt
new file mode 100644 (file)
index 0000000..74c3ff3
--- /dev/null
@@ -0,0 +1,2 @@
+This tests what happens when class A implements interface B, but somebody
+turns B into an abstract class without rebuilding A.
diff --git a/test/065-mismatched-implements/src/Base.java b/test/065-mismatched-implements/src/Base.java
new file mode 100644 (file)
index 0000000..8623ad7
--- /dev/null
@@ -0,0 +1,7 @@
+// Copyright 2008 The Android Open Source Project
+
+public class Base implements Defs {
+    public void func() {
+        System.out.println("whee");
+    }
+};
diff --git a/test/065-mismatched-implements/src/Defs.java b/test/065-mismatched-implements/src/Defs.java
new file mode 100644 (file)
index 0000000..bab92d8
--- /dev/null
@@ -0,0 +1,7 @@
+// Copyright 2008 The Android Open Source Project
+
+public interface Defs {
+    public void func();
+
+    // func2 not defined
+}
diff --git a/test/065-mismatched-implements/src/Indirect.java b/test/065-mismatched-implements/src/Indirect.java
new file mode 100644 (file)
index 0000000..023e409
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/**
+ * Error indirection class.
+ *
+ * Some VMs will load this class and fail on the "new" call, others will
+ * refuse to load this class at all.
+ */
+public class Indirect {
+    public static void main() {
+        Base base = new Base();
+    }
+}
diff --git a/test/065-mismatched-implements/src/Main.java b/test/065-mismatched-implements/src/Main.java
new file mode 100644 (file)
index 0000000..5975b99
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/*
+ * Test field access through reflection.
+ */
+public class Main {
+    public static void main(String[] args) {
+        try {
+            Indirect.main();
+            System.err.println("Succeeded unexpectedly");
+        } catch (IncompatibleClassChangeError icce) {
+            System.out.println("Got expected ICCE");
+        }
+    }
+}
diff --git a/test/065-mismatched-implements/src2/Defs.java b/test/065-mismatched-implements/src2/Defs.java
new file mode 100644 (file)
index 0000000..e7eb8a1
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2008 The Android Open Source Project
+
+public abstract class Defs {
+    public void func() {
+        System.out.println("yo");
+    }
+
+    public void func2() {
+        System.out.println("yo yo");
+    }
+}
diff --git a/test/066-mismatched-super/expected.txt b/test/066-mismatched-super/expected.txt
new file mode 100644 (file)
index 0000000..09c0596
--- /dev/null
@@ -0,0 +1 @@
+Got expected ICCE
diff --git a/test/066-mismatched-super/info.txt b/test/066-mismatched-super/info.txt
new file mode 100644 (file)
index 0000000..7865ffc
--- /dev/null
@@ -0,0 +1,2 @@
+This tests what happens when class A extends abstract class B, but somebody
+turns B into an interface without rebuilding A.
diff --git a/test/066-mismatched-super/src/Base.java b/test/066-mismatched-super/src/Base.java
new file mode 100644 (file)
index 0000000..6180c8b
--- /dev/null
@@ -0,0 +1,5 @@
+// Copyright 2008 The Android Open Source Project
+
+public class Base extends Defs {
+    // no need to implement func(), provided by abstract class
+};
diff --git a/test/066-mismatched-super/src/Defs.java b/test/066-mismatched-super/src/Defs.java
new file mode 100644 (file)
index 0000000..e7eb8a1
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2008 The Android Open Source Project
+
+public abstract class Defs {
+    public void func() {
+        System.out.println("yo");
+    }
+
+    public void func2() {
+        System.out.println("yo yo");
+    }
+}
diff --git a/test/066-mismatched-super/src/Indirect.java b/test/066-mismatched-super/src/Indirect.java
new file mode 100644 (file)
index 0000000..023e409
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/**
+ * Error indirection class.
+ *
+ * Some VMs will load this class and fail on the "new" call, others will
+ * refuse to load this class at all.
+ */
+public class Indirect {
+    public static void main() {
+        Base base = new Base();
+    }
+}
diff --git a/test/066-mismatched-super/src/Main.java b/test/066-mismatched-super/src/Main.java
new file mode 100644 (file)
index 0000000..5975b99
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/*
+ * Test field access through reflection.
+ */
+public class Main {
+    public static void main(String[] args) {
+        try {
+            Indirect.main();
+            System.err.println("Succeeded unexpectedly");
+        } catch (IncompatibleClassChangeError icce) {
+            System.out.println("Got expected ICCE");
+        }
+    }
+}
diff --git a/test/066-mismatched-super/src2/Defs.java b/test/066-mismatched-super/src2/Defs.java
new file mode 100644 (file)
index 0000000..bab92d8
--- /dev/null
@@ -0,0 +1,7 @@
+// Copyright 2008 The Android Open Source Project
+
+public interface Defs {
+    public void func();
+
+    // func2 not defined
+}
diff --git a/test/067-preemptive-unpark/expected.txt b/test/067-preemptive-unpark/expected.txt
new file mode 100644 (file)
index 0000000..12bfee0
--- /dev/null
@@ -0,0 +1,5 @@
+Test starting
+GC'ing
+Asking thread to park
+park() returned quickly
+Test succeeded!
diff --git a/test/067-preemptive-unpark/info.txt b/test/067-preemptive-unpark/info.txt
new file mode 100644 (file)
index 0000000..0bc0c61
--- /dev/null
@@ -0,0 +1 @@
+Test that Unsafe.unpark() operates as expected, in particular across a gc.
diff --git a/test/067-preemptive-unpark/src/Main.java b/test/067-preemptive-unpark/src/Main.java
new file mode 100644 (file)
index 0000000..a16219e
--- /dev/null
@@ -0,0 +1,107 @@
+import sun.misc.Unsafe;
+
+import java.lang.reflect.Field;
+
+public class Main {
+    private static Unsafe UNSAFE;
+
+    public static void main(String[] args) throws Exception {
+        setUp();
+
+        ParkTester test = new ParkTester();
+
+        System.out.println("Test starting");
+
+        test.start();
+        UNSAFE.unpark(test);
+        clearStack(10);
+
+        System.out.println("GC'ing");
+        System.gc();
+        System.gc();
+
+        System.out.println("Asking thread to park");
+        test.parkNow = true;
+
+        try {
+            Thread.sleep(1500);
+        } catch (InterruptedException ex) {
+            // Ignore it.
+        }
+
+        if (test.success) {
+            System.out.println("Test succeeded!");
+        } else {
+            System.out.println("Test failed.");
+        }
+    }
+
+    /**
+     * Set up {@link #UNSAFE}.
+     */
+    public static void setUp() {
+        /*
+         * Subvert the access check to get the unique Unsafe instance.
+         * We can do this because there's no security manager
+         * installed when running the test.
+         */
+        try {
+            Field field = Unsafe.class.getDeclaredField("THE_ONE");
+            field.setAccessible(true);
+
+            UNSAFE = (Unsafe) field.get(null);
+        } catch (NoSuchFieldException ex) {
+            throw new RuntimeException(ex);
+        } catch (IllegalAccessException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    /**
+     * Scribbles on the stack to help ensure we don't have a fake
+     * pointer that would keep would-be garbage alive.
+     */
+    private static void clearStack(int depth) {
+        int a = 0;
+        int b = 0;
+        int c = 0;
+        int d = 0;
+        int e = 0;
+        int f = 0;
+        int g = 0;
+        int h = 0;
+        int i = 0;
+        int j = 0;
+
+        if (depth > 0) {
+            clearStack(depth - 1);
+        }
+    }
+
+    private static class ParkTester extends Thread {
+        public volatile boolean parkNow = false;
+        public volatile boolean success = false;
+
+        public void run() {
+            while (!parkNow) {
+                try {
+                    Thread.sleep(500);
+                } catch (InterruptedException ex) {
+                    // Ignore it.
+                }
+            }
+
+            long start = System.currentTimeMillis();
+            UNSAFE.park(false, 500 * 1000000); // 500 msec
+            long elapsed = System.currentTimeMillis() - start;
+
+            if (elapsed > 200) {
+                System.out.println("park()ed for " + elapsed + " msec");
+                success = false;
+            } else {
+                System.out.println("park() returned quickly");
+                success = true;
+            }
+        }
+    }
+}
diff --git a/test/068-classloader/expected.txt b/test/068-classloader/expected.txt
new file mode 100644 (file)
index 0000000..bf131ee
--- /dev/null
@@ -0,0 +1,13 @@
+base: class DoubledImplement
+base2: class DoubledImplement2
+Got expected access exception #1
+Got expected CNFE/IAE #2
+Got expected CNFE/IAE #3
+Got expected LinkageError on DE
+Got DEO result DoubledExtendOkay 1
+Got LinkageError on GD
+Got LinkageError on TA
+Ctor: doubled implement, type 1
+DoubledImplement one
+Got LinkageError on DI (early)
+Got LinkageError on IDI (early)
diff --git a/test/068-classloader/info.txt b/test/068-classloader/info.txt
new file mode 100644 (file)
index 0000000..421e52a
--- /dev/null
@@ -0,0 +1,8 @@
+Class loaders allow code to "redefine" a given class, e.g. it's possible to
+have multiple classes called "com.android.Blah" loaded simultaneously.  The
+classes are distinct and must be treated as such.  This test exercises
+some situations in which a VM that only checks the UTF-8 signatures could
+mix things up.
+
+This also tests a couple of situations in which an IllegalAccessException
+is expected.
diff --git a/test/068-classloader/src-ex/AbstractGet.java b/test/068-classloader/src-ex/AbstractGet.java
new file mode 100644 (file)
index 0000000..db13b32
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+/**
+ * Verify that we don't reject this with a LinkageError.
+ */
+public class AbstractGet extends AbstractBase {
+    public DoubledExtendOkay getExtended() {
+        return new DoubledExtendOkay();
+    }
+}
+
+/**
+ * Abstract class, does not declare getAbstract.  This cause the VM to
+ * generate a "miranda" method.
+ */
+abstract class AbstractBase extends BaseOkay {
+    public abstract DoubledExtendOkay getExtended();
+}
diff --git a/test/068-classloader/src-ex/DoubledExtend.java b/test/068-classloader/src-ex/DoubledExtend.java
new file mode 100644 (file)
index 0000000..6ad2708
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2008 The Android Open Source Project
+
+/**
+ * Doubled sub-class, form #2.
+ */
+public class DoubledExtend extends Base {
+    public DoubledExtend() {
+        //System.out.println("Ctor: doubled extend, type 2");
+    }
+
+    @Override
+    public DoubledExtend getExtended() {
+        //System.out.println("getExtended 2");
+        return new DoubledExtend();
+    }
+
+    public String getStr() {
+        return "DoubledExtend 2";
+    }
+}
diff --git a/test/068-classloader/src-ex/DoubledExtendOkay.java b/test/068-classloader/src-ex/DoubledExtendOkay.java
new file mode 100644 (file)
index 0000000..9674875
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+/**
+ * "Okay" doubled sub-class, form #2.
+ */
+public class DoubledExtendOkay extends BaseOkay {
+    public DoubledExtendOkay() {
+        //System.out.println("Ctor: doubled extend okay, type 2");
+    }
+
+    /*
+    @Override
+    public DoubledExtendOkay getExtended() {
+        //System.out.println("getExtended 2");
+        return new DoubledExtendOkay();
+    }
+    */
+
+    public String getStr() {
+        return "DoubledExtendOkay 2";
+    }
+}
diff --git a/test/068-classloader/src-ex/DoubledImplement.java b/test/068-classloader/src-ex/DoubledImplement.java
new file mode 100644 (file)
index 0000000..5c44fc3
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2008 The Android Open Source Project
+
+/**
+ * Doubled sub-class, form #2.
+ */
+public class DoubledImplement implements ICommon {
+    public DoubledImplement() {
+        System.out.println("Ctor: doubled implement, type 2");
+    }
+
+    public DoubledImplement getDoubledInstance() {
+        return new DoubledImplement();
+    }
+
+    public void two() {
+        System.out.println("DoubledImplement two");
+    }
+}
diff --git a/test/068-classloader/src-ex/DoubledImplement2.java b/test/068-classloader/src-ex/DoubledImplement2.java
new file mode 100644 (file)
index 0000000..24ecb65
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/**
+ * Another doubled sub-class, form #2.
+ */
+public class DoubledImplement2 implements ICommon2 {
+    public DoubledImplement2() {
+        System.out.println("Ctor: doubled implement, type 2");
+    }
+
+    public DoubledImplement2 getDoubledInstance2() {
+        return new DoubledImplement2();
+    }
+
+    public void two() {
+        System.out.println("DoubledImplement2 two");
+    }
+}
diff --git a/test/068-classloader/src-ex/GetDoubled.java b/test/068-classloader/src-ex/GetDoubled.java
new file mode 100644 (file)
index 0000000..28ada1e
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/*
+ * The interface we implement was declared in a different class loader,
+ * which means the DoubledExtend we return is not the one it was declared
+ * to return.
+ */
+public class GetDoubled implements IGetDoubled {
+    public DoubledExtendOkay getDoubled() {
+        return new DoubledExtendOkay();
+    }
+}
diff --git a/test/068-classloader/src-ex/IfaceImpl.java b/test/068-classloader/src-ex/IfaceImpl.java
new file mode 100644 (file)
index 0000000..7e9c27d
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+public class IfaceImpl implements IfaceSub {
+    public DoubledImplement2 getDoubledInstance2() {
+        return new DoubledImplement2();
+    }
+}
diff --git a/test/068-classloader/src-ex/IfaceSub.java b/test/068-classloader/src-ex/IfaceSub.java
new file mode 100644 (file)
index 0000000..7e512e7
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+public interface IfaceSub extends IfaceSuper {
+    public DoubledImplement2 getDoubledInstance2();
+}
diff --git a/test/068-classloader/src-ex/Inaccessible1.java b/test/068-classloader/src-ex/Inaccessible1.java
new file mode 100644 (file)
index 0000000..415a8a1
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2008 The Android Open Source Project
+
+/**
+ * Non-public class, inaccessible from Main.  Note the constructor is
+ * public.
+ */
+class Inaccessible1 extends SimpleBase {
+    public Inaccessible1() {
+        System.out.println("--- inaccessible1");
+    }
+}
diff --git a/test/068-classloader/src-ex/Inaccessible2.java b/test/068-classloader/src-ex/Inaccessible2.java
new file mode 100644 (file)
index 0000000..dc20c21
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright 2008 The Android Open Source Project
+
+/**
+ * Public class that can't access its base.
+ */
+public class Inaccessible2 extends InaccessibleBase {
+    public Inaccessible2() {
+        System.out.println("--- inaccessible2");
+    }
+}
diff --git a/test/068-classloader/src-ex/Inaccessible3.java b/test/068-classloader/src-ex/Inaccessible3.java
new file mode 100644 (file)
index 0000000..771d0f7
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright 2008 The Android Open Source Project
+
+/**
+ * Public class that can't access its interface.
+ */
+public class Inaccessible3 implements InaccessibleInterface {
+    public Inaccessible3() {
+        System.out.println("--- inaccessible3");
+    }
+}
diff --git a/test/068-classloader/src/Base.java b/test/068-classloader/src/Base.java
new file mode 100644 (file)
index 0000000..b297a8a
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2008 The Android Open Source Project
+
+/**
+ * Common base class.
+ */
+public class Base {
+    public Base() {}
+
+    public DoubledExtend getExtended() {
+        return new DoubledExtend();
+    }
+
+    public static String doStuff(DoubledExtend dt) {
+        return dt.getStr();
+    }
+}
diff --git a/test/068-classloader/src/BaseOkay.java b/test/068-classloader/src/BaseOkay.java
new file mode 100644 (file)
index 0000000..48b7796
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+/**
+ * Common base class.
+ */
+public class BaseOkay implements IDoubledExtendOkay {
+    public BaseOkay() {}
+
+    public DoubledExtendOkay getExtended() {
+        return new DoubledExtendOkay();
+    }
+
+    public static String doStuff(DoubledExtendOkay dt) {
+        return dt.getStr();
+    }
+}
+
+/**
+ * Interface that declares the not-overridden method.  This exists to ensure
+ * that the existence of an interface doesn't trip the check.
+ */
+interface IDoubledExtendOkay {
+    public DoubledExtendOkay getExtended();
+}
diff --git a/test/068-classloader/src/DoubledExtend.java b/test/068-classloader/src/DoubledExtend.java
new file mode 100644 (file)
index 0000000..5f8ebc2
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2008 The Android Open Source Project
+
+/**
+ * Doubled sub-class, form #1.
+ */
+public class DoubledExtend extends Base {
+    public DoubledExtend() {
+        //System.out.println("Ctor: doubled extend, type 1");
+    }
+
+    @Override
+    public DoubledExtend getExtended() {
+        System.out.println("getExtended 1");
+        return new DoubledExtend();
+    }
+
+    public String getStr() {
+        return "DoubledExtend 1";
+    }
+}
diff --git a/test/068-classloader/src/DoubledExtendOkay.java b/test/068-classloader/src/DoubledExtendOkay.java
new file mode 100644 (file)
index 0000000..e226e5f
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+/**
+ * "Okay" doubled sub-class, form #1.
+ */
+public class DoubledExtendOkay extends BaseOkay {
+    public DoubledExtendOkay() {
+        //System.out.println("Ctor: doubled extend okay, type 1");
+    }
+
+    /*
+    @Override
+    public DoubledExtendOkay getExtended() {
+        System.out.println("getExtended 1");
+        return new DoubledExtendOkay();
+    }
+    */
+
+    public String getStr() {
+        return "DoubledExtendOkay 1";
+    }
+}
diff --git a/test/068-classloader/src/DoubledImplement.java b/test/068-classloader/src/DoubledImplement.java
new file mode 100644 (file)
index 0000000..64ec5e2
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2008 The Android Open Source Project
+
+/**
+ * Doubled sub-class, form #1.
+ */
+class DoubledImplement implements ICommon {
+    public DoubledImplement() {
+        System.out.println("Ctor: doubled implement, type 1");
+    }
+
+    public DoubledImplement getDoubledInstance() {
+        return new DoubledImplement();
+    }
+
+    public void one() {
+        System.out.println("DoubledImplement one");
+    }
+}
diff --git a/test/068-classloader/src/DoubledImplement2.java b/test/068-classloader/src/DoubledImplement2.java
new file mode 100644 (file)
index 0000000..12c036c
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/**
+ * Another doubled sub-class, form #1.
+ */
+public class DoubledImplement2 implements ICommon2 {
+    public DoubledImplement2() {
+        System.out.println("Ctor: doubled implement, type 1");
+    }
+
+    public DoubledImplement2 getDoubledInstance2() {
+        return new DoubledImplement2();
+    }
+
+    public void one() {
+        System.out.println("DoubledImplement2 one");
+    }
+}
diff --git a/test/068-classloader/src/FancyLoader.java b/test/068-classloader/src/FancyLoader.java
new file mode 100644 (file)
index 0000000..173b08f
--- /dev/null
@@ -0,0 +1,228 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * A class loader with atypical behavior: we try to load a private
+ * class implementation before asking the system or boot loader.  This
+ * is used to create multiple classes with identical names in a single VM.
+ *
+ * If DexFile is available, we use that; if not, we assume we're not in
+ * Dalvik and instantiate the class with defineClass().
+ *
+ * The location of the DEX files and class data is dependent upon the
+ * test framework.
+ */
+public class FancyLoader extends ClassLoader {
+    /* this is where the "alternate" .class files live */
+    static final String CLASS_PATH = "classes-ex/";
+
+    /* this is the "alternate" DEX/Jar file */
+    static final String DEX_FILE = "test-ex.jar";
+
+    /* on Dalvik, this is a DexFile; otherwise, it's null */
+    private Class mDexClass;
+
+    private Object mDexFile;
+
+    /**
+     * Construct FancyLoader, grabbing a reference to the DexFile class
+     * if we're running under Dalvik.
+     */
+    public FancyLoader(ClassLoader parent) {
+        super(parent);
+
+        try {
+            mDexClass = parent.loadClass("dalvik/system/DexFile");
+        } catch (ClassNotFoundException cnfe) {
+            // ignore -- not running Dalvik
+        }
+    }
+
+    /**
+     * Finds the class with the specified binary name.
+     *
+     * We search for a file in CLASS_PATH or pull an entry from DEX_FILE.
+     * If we don't find a match, we throw an exception.
+     */
+    protected Class<?> findClass(String name) throws ClassNotFoundException
+    {
+        if (mDexClass != null) {
+            return findClassDalvik(name);
+        } else {
+            return findClassNonDalvik(name);
+        }
+    }
+
+    /**
+     * Finds the class with the specified binary name, from a DEX file.
+     */
+    private Class<?> findClassDalvik(String name)
+        throws ClassNotFoundException {
+
+        if (mDexFile == null) {
+            synchronized (FancyLoader.class) {
+                Constructor ctor;
+                /*
+                 * Construct a DexFile object through reflection.
+                 */
+                try {
+                    ctor = mDexClass.getConstructor(new Class[] {String.class});
+                } catch (NoSuchMethodException nsme) {
+                    throw new ClassNotFoundException("getConstructor failed",
+                        nsme);
+                }
+
+                try {
+                    mDexFile = ctor.newInstance(DEX_FILE);
+                } catch (InstantiationException ie) {
+                    throw new ClassNotFoundException("newInstance failed", ie);
+                } catch (IllegalAccessException iae) {
+                    throw new ClassNotFoundException("newInstance failed", iae);
+                } catch (InvocationTargetException ite) {
+                    throw new ClassNotFoundException("newInstance failed", ite);
+                }
+            }
+        }
+
+        /*
+         * Call DexFile.loadClass(String, ClassLoader).
+         */
+        Method meth;
+
+        try {
+            meth = mDexClass.getMethod("loadClass",
+                    new Class[] { String.class, ClassLoader.class });
+        } catch (NoSuchMethodException nsme) {
+            throw new ClassNotFoundException("getMethod failed", nsme);
+        }
+
+        try {
+            meth.invoke(mDexFile, name, this);
+        } catch (IllegalAccessException iae) {
+            throw new ClassNotFoundException("loadClass failed", iae);
+        } catch (InvocationTargetException ite) {
+            throw new ClassNotFoundException("loadClass failed",
+                ite.getCause());
+        }
+
+        return null;
+    }
+
+    /**
+     * Finds the class with the specified binary name, from .class files.
+     */
+    private Class<?> findClassNonDalvik(String name)
+        throws ClassNotFoundException {
+
+        String pathName = CLASS_PATH + name + ".class";
+        //System.out.println("--- Fancy: looking for " + pathName);
+
+        File path = new File(pathName);
+        RandomAccessFile raf;
+
+        try {
+            raf = new RandomAccessFile(path, "r");
+        } catch (FileNotFoundException fnfe) {
+            throw new ClassNotFoundException("Not found: " + pathName);
+        }
+
+        /* read the entire file in */
+        byte[] fileData;
+        try {
+            fileData = new byte[(int) raf.length()];
+            raf.readFully(fileData);
+        } catch (IOException ioe) {
+            throw new ClassNotFoundException("Read error: " + pathName);
+        } finally {
+            try {
+                raf.close();
+            } catch (IOException ioe) {
+                // drop
+            }
+        }
+
+        /* create the class */
+        //System.out.println("--- Fancy: defining " + name);
+        try {
+            return defineClass(name, fileData, 0, fileData.length);
+        } catch (Throwable th) {
+            throw new ClassNotFoundException("defineClass failed", th);
+        }
+    }
+
+    /**
+     * Load a class.
+     *
+     * Normally a class loader wouldn't override this, but we want our
+     * version of the class to take precedence over an already-loaded
+     * version.
+     *
+     * We still want the system classes (e.g. java.lang.Object) from the
+     * bootstrap class loader.
+     */
+    protected Class<?> loadClass(String name, boolean resolve)
+        throws ClassNotFoundException
+    {
+        Class res;
+
+        /*
+         * 1. Invoke findLoadedClass(String) to check if the class has
+         * already been loaded.
+         *
+         * This doesn't change.
+         */
+        res = findLoadedClass(name);
+        if (res != null) {
+            System.out.println("FancyLoader.loadClass: "
+                + name + " already loaded");
+            if (resolve)
+                resolveClass(res);
+            return res;
+        }
+
+        /*
+         * 3. Invoke the findClass(String) method to find the class.
+         */
+        try {
+            res = findClass(name);
+            if (resolve)
+                resolveClass(res);
+        }
+        catch (ClassNotFoundException e) {
+            // we couldn't find it, so eat the exception and keep going
+        }
+
+        /*
+         * 2. Invoke the loadClass method on the parent class loader.  If
+         * the parent loader is null the class loader built-in to the
+         * virtual machine is used, instead.
+         *
+         * (Since we're not in java.lang, we can't actually invoke the
+         * parent's loadClass() method, but we passed our parent to the
+         * super-class which can take care of it for us.)
+         */
+        res = super.loadClass(name, resolve);   // returns class or throws
+        return res;
+    }
+}
diff --git a/test/068-classloader/src/ICommon.java b/test/068-classloader/src/ICommon.java
new file mode 100644 (file)
index 0000000..35a98cc
--- /dev/null
@@ -0,0 +1,8 @@
+// Copyright 2008 The Android Open Source Project
+
+/**
+ * Common interface.
+ */
+public interface ICommon {
+    public DoubledImplement getDoubledInstance();
+}
diff --git a/test/068-classloader/src/ICommon2.java b/test/068-classloader/src/ICommon2.java
new file mode 100644 (file)
index 0000000..6d81afc
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/**
+ * Common interface.
+ */
+public interface ICommon2 {
+    public DoubledImplement2 getDoubledInstance2();
+}
diff --git a/test/068-classloader/src/IGetDoubled.java b/test/068-classloader/src/IGetDoubled.java
new file mode 100644 (file)
index 0000000..08cd1ce
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+/**
+ * Interface, loaded from one loader, used from another.
+ */
+public interface IGetDoubled {
+    public DoubledExtendOkay getDoubled();
+}
diff --git a/test/068-classloader/src/IfaceSuper.java b/test/068-classloader/src/IfaceSuper.java
new file mode 100644 (file)
index 0000000..36d278c
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+public interface IfaceSuper {
+    public DoubledImplement2 getDoubledInstance2();
+}
diff --git a/test/068-classloader/src/InaccessibleBase.java b/test/068-classloader/src/InaccessibleBase.java
new file mode 100644 (file)
index 0000000..83af665
--- /dev/null
@@ -0,0 +1,7 @@
+// Copyright 2008 The Android Open Source Project
+
+/**
+ * Non-public base class, inaccessible from alternate class loader.
+ */
+class InaccessibleBase {
+}
diff --git a/test/068-classloader/src/InaccessibleInterface.java b/test/068-classloader/src/InaccessibleInterface.java
new file mode 100644 (file)
index 0000000..7f52b80
--- /dev/null
@@ -0,0 +1,7 @@
+// Copyright 2008 The Android Open Source Project
+
+/**
+ * Non-public interface class, inaccessible from alternate class loader.
+ */
+interface InaccessibleInterface {
+}
diff --git a/test/068-classloader/src/Main.java b/test/068-classloader/src/Main.java
new file mode 100644 (file)
index 0000000..1bc7b04
--- /dev/null
@@ -0,0 +1,425 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+/**
+ * Class loader test.
+ */
+public class Main {
+    /**
+     * Main entry point.
+     */
+    public static void main(String[] args) {
+        FancyLoader loader;
+
+        loader = new FancyLoader(ClassLoader.getSystemClassLoader());
+        //System.out.println("SYSTEM: " + ClassLoader.getSystemClassLoader());
+        //System.out.println("ALTERN: " + loader);
+
+        /*
+         * This statement has no effect on this program, but it can
+         * change the point where a LinkageException is thrown in
+         * testImplement().  When this is present the "reference
+         * implementation" throws an exception from Class.newInstance(),
+         * when it's absent the exception is deferred until the first time
+         * we call a method that isn't actually implemented.
+         *
+         * This isn't the class that fails -- it's a class with the same
+         * name in the "fancy" class loader --  but the VM thinks it has a
+         * reference to one of these; presumably the difference is that
+         * without this the VM finds itself holding a reference to an
+         * instance of an uninitialized class.
+         */
+        System.out.println("base: " + DoubledImplement.class);
+        System.out.println("base2: " + DoubledImplement2.class);
+
+        /*
+         * Run tests.
+         */
+        testAccess1(loader);
+        testAccess2(loader);
+        testAccess3(loader);
+
+        testExtend(loader);
+        testExtendOkay(loader);
+        testInterface(loader);
+        testAbstract(loader);
+        testImplement(loader);
+        testIfaceImplement(loader);
+    }
+
+    /**
+     * See if we can load a class that isn't public to us.  We should be
+     * able to load it but not instantiate it.
+     */
+    static void testAccess1(ClassLoader loader) {
+        Class altClass;
+
+        try {
+            altClass = loader.loadClass("Inaccessible1");
+        } catch (ClassNotFoundException cnfe) {
+            System.err.println("loadClass failed");
+            cnfe.printStackTrace();
+            return;
+        }
+
+        /* instantiate */
+        Object obj;
+        try {
+            obj = altClass.newInstance();
+            System.err.println("ERROR: Inaccessible1 was accessible");
+        } catch (InstantiationException ie) {
+            System.err.println("newInstance failed: " + ie);
+            return;
+        } catch (IllegalAccessException iae) {
+            System.out.println("Got expected access exception #1");
+            //System.out.println("+++ " + iae);
+            return;
+        }
+    }
+
+    /**
+     * See if we can load a class whose base class is not accessible to it
+     * (though the base *is* accessible to us).
+     */
+    static void testAccess2(ClassLoader loader) {
+        Class altClass;
+
+        try {
+            altClass = loader.loadClass("Inaccessible2");
+            System.err.println("ERROR: Inaccessible2 was accessible");
+        } catch (ClassNotFoundException cnfe) {
+            Throwable cause = cnfe.getCause();
+            if (cause instanceof IllegalAccessError) {
+                System.out.println("Got expected CNFE/IAE #2");
+            } else {
+                System.err.println("Got unexpected CNFE/IAE #2");
+                cnfe.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * See if we can load a class with an inaccessible interface.
+     */
+    static void testAccess3(ClassLoader loader) {
+        Class altClass;
+
+        try {
+            altClass = loader.loadClass("Inaccessible3");
+            System.err.println("ERROR: Inaccessible3 was accessible");
+        } catch (ClassNotFoundException cnfe) {
+            Throwable cause = cnfe.getCause();
+            if (cause instanceof IllegalAccessError) {
+                System.out.println("Got expected CNFE/IAE #3");
+            } else {
+                System.err.println("Got unexpected CNFE/IAE #3");
+                cnfe.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * Test a doubled class that extends the base class.
+     */
+    static void testExtend(ClassLoader loader) {
+        Class doubledExtendClass;
+        Object obj;
+
+        /* get the "alternate" version of DoubledExtend */
+        try {
+            doubledExtendClass = loader.loadClass("DoubledExtend");
+            //System.out.println("+++ DoubledExtend is " + doubledExtendClass
+            //    + " in " + doubledExtendClass.getClassLoader());
+        } catch (ClassNotFoundException cnfe) {
+            System.err.println("loadClass failed: " + cnfe);
+            return;
+        }
+
+        /* instantiate */
+        try {
+            obj = doubledExtendClass.newInstance();
+        } catch (InstantiationException ie) {
+            System.err.println("newInstance failed: " + ie);
+            return;
+        } catch (IllegalAccessException iae) {
+            System.err.println("newInstance failed: " + iae);
+            return;
+        } catch (LinkageError le) {
+            System.out.println("Got expected LinkageError on DE");
+            return;
+        }
+
+        /* use the base class reference to get a CL-specific instance */
+        Base baseRef = (Base) obj;
+        DoubledExtend de = baseRef.getExtended();
+
+        /* try to call through it */
+        try {
+            String result;
+
+            result = Base.doStuff(de);
+            System.err.println("ERROR: did not get LinkageError on DE");
+            System.err.println("(result=" + result + ")");
+        } catch (LinkageError le) {
+            System.out.println("Got expected LinkageError on DE");
+            return;
+        }
+    }
+
+    /**
+     * Test a doubled class that extends the base class, but is okay since
+     * it doesn't override the base class method.
+     */
+    static void testExtendOkay(ClassLoader loader) {
+        Class doubledExtendOkayClass;
+        Object obj;
+
+        /* get the "alternate" version of DoubledExtendOkay */
+        try {
+            doubledExtendOkayClass = loader.loadClass("DoubledExtendOkay");
+        } catch (ClassNotFoundException cnfe) {
+            System.err.println("loadClass failed: " + cnfe);
+            return;
+        }
+
+        /* instantiate */
+        try {
+            obj = doubledExtendOkayClass.newInstance();
+        } catch (InstantiationException ie) {
+            System.err.println("newInstance failed: " + ie);
+            return;
+        } catch (IllegalAccessException iae) {
+            System.err.println("newInstance failed: " + iae);
+            return;
+        } catch (LinkageError le) {
+            System.err.println("Got unexpected LinkageError on DEO");
+            le.printStackTrace();
+            return;
+        }
+
+        /* use the base class reference to get a CL-specific instance */
+        BaseOkay baseRef = (BaseOkay) obj;
+        DoubledExtendOkay de = baseRef.getExtended();
+
+        /* try to call through it */
+        try {
+            String result;
+
+            result = BaseOkay.doStuff(de);
+            System.out.println("Got DEO result " + result);
+        } catch (LinkageError le) {
+            System.err.println("Got unexpected LinkageError on DEO");
+            le.printStackTrace();
+            return;
+        }
+    }
+
+    /**
+     * Try to access a doubled class through a class that implements
+     * an interface declared in a different class.
+     */
+    static void testInterface(ClassLoader loader) {
+        Class getDoubledClass;
+        Object obj;
+
+        /* get GetDoubled from the "alternate" class loader */
+        try {
+            getDoubledClass = loader.loadClass("GetDoubled");
+        } catch (ClassNotFoundException cnfe) {
+            System.err.println("loadClass failed: " + cnfe);
+            return;
+        }
+
+        /* instantiate */
+        try {
+            obj = getDoubledClass.newInstance();
+        } catch (InstantiationException ie) {
+            System.err.println("newInstance failed: " + ie);
+            return;
+        } catch (IllegalAccessException iae) {
+            System.err.println("newInstance failed: " + iae);
+            return;
+        } catch (LinkageError le) {
+            // Dalvik bails here
+            System.out.println("Got LinkageError on GD");
+            return;
+        }
+
+        /*
+         * Cast the object to the interface, and try to use it.
+         */
+        IGetDoubled iface = (IGetDoubled) obj;
+        try {
+            /* "de" will be the wrong variety of DoubledExtendOkay */
+            DoubledExtendOkay de = iface.getDoubled();
+            // reference impl bails here
+            String str = de.getStr();
+        } catch (LinkageError le) {
+            System.out.println("Got LinkageError on GD");
+            return;
+        }
+        System.err.println("Should have failed by now on GetDoubled");
+    }
+
+    /**
+     * Throw an abstract class into the middle and see what happens.
+     */
+    static void testAbstract(ClassLoader loader) {
+        Class abstractGetClass;
+        Object obj;
+
+        /* get AbstractGet from the "alternate" loader */
+        try {
+            abstractGetClass = loader.loadClass("AbstractGet");
+        } catch (ClassNotFoundException cnfe) {
+            System.err.println("loadClass ta failed: " + cnfe);
+            return;
+        }
+
+        /* instantiate */
+        try {
+            obj = abstractGetClass.newInstance();
+        } catch (InstantiationException ie) {
+            System.err.println("newInstance failed: " + ie);
+            return;
+        } catch (IllegalAccessException iae) {
+            System.err.println("newInstance failed: " + iae);
+            return;
+        } catch (LinkageError le) {
+            System.out.println("Got LinkageError on TA");
+            return;
+        }
+
+        /* use the base class reference to get a CL-specific instance */
+        BaseOkay baseRef = (BaseOkay) obj;
+        DoubledExtendOkay de = baseRef.getExtended();
+
+        /* try to call through it */
+        try {
+            String result;
+
+            result = BaseOkay.doStuff(de);
+        } catch (LinkageError le) {
+            System.out.println("Got LinkageError on TA");
+            return;
+        }
+        System.err.println("Should have failed by now in testAbstract");
+    }
+
+    /**
+     * Test a doubled class that implements a common interface.
+     */
+    static void testImplement(ClassLoader loader) {
+        Class doubledImplementClass;
+        Object obj;
+
+        useImplement(new DoubledImplement(), true);
+
+        /* get the "alternate" version of DoubledImplement */
+        try {
+            doubledImplementClass = loader.loadClass("DoubledImplement");
+        } catch (ClassNotFoundException cnfe) {
+            System.err.println("loadClass failed: " + cnfe);
+            return;
+        }
+
+        /* instantiate */
+        try {
+            obj = doubledImplementClass.newInstance();
+        } catch (InstantiationException ie) {
+            System.err.println("newInstance failed: " + ie);
+            return;
+        } catch (IllegalAccessException iae) {
+            System.err.println("newInstance failed: " + iae);
+            return;
+        } catch (LinkageError le) {
+            System.out.println("Got LinkageError on DI (early)");
+            return;
+        }
+
+        /* if we lived this long, try to do something with it */
+        ICommon icommon = (ICommon) obj;
+        useImplement(icommon.getDoubledInstance(), false);
+    }
+
+    /**
+     * Do something with a DoubledImplement instance.
+     */
+    static void useImplement(DoubledImplement di, boolean isOne) {
+        //System.out.println("useObject: " + di.toString() + " -- "
+        //    + di.getClass().getClassLoader());
+        try {
+            di.one();
+            if (!isOne) {
+                System.err.println("ERROR: did not get LinkageError on DI");
+            }
+        } catch (LinkageError le) {
+            if (!isOne) {
+                System.out.println("Got LinkageError on DI (late)");
+            } else {
+                throw le;
+            }
+        }
+    }
+
+
+    /**
+     * Test a class that implements an interface with a super-interface
+     * that refers to a doubled class.
+     */
+    static void testIfaceImplement(ClassLoader loader) {
+        Class ifaceImplClass;
+        Object obj;
+
+        /*
+         * Create an instance of IfaceImpl.  We also pull in
+         * DoubledImplement2 from the other class loader; without this
+         * we don't fail in some implementations.
+         */
+        try {
+            ifaceImplClass = loader.loadClass("IfaceImpl");
+            ifaceImplClass = loader.loadClass("DoubledImplement2");
+        } catch (ClassNotFoundException cnfe) {
+            System.err.println("loadClass failed: " + cnfe);
+            return;
+        }
+
+        /* instantiate */
+        try {
+            obj = ifaceImplClass.newInstance();
+        } catch (InstantiationException ie) {
+            System.err.println("newInstance failed: " + ie);
+            return;
+        } catch (IllegalAccessException iae) {
+            System.err.println("newInstance failed: " + iae);
+            return;
+        } catch (LinkageError le) {
+            System.out.println("Got LinkageError on IDI (early)");
+            //System.out.println(le);
+            return;
+        }
+
+        /*
+         * Without the pre-load of FancyLoader->DoubledImplement2, some
+         * implementations will happily execute through this part.  "obj"
+         * comes from FancyLoader, but the di2 returned from ifaceSuper
+         * comes from the application class loader.
+         */
+        IfaceSuper ifaceSuper = (IfaceSuper) obj;
+        DoubledImplement2 di2 = ifaceSuper.getDoubledInstance2();
+        di2.one();
+    }
+}
diff --git a/test/068-classloader/src/SimpleBase.java b/test/068-classloader/src/SimpleBase.java
new file mode 100644 (file)
index 0000000..fd56db9
--- /dev/null
@@ -0,0 +1,8 @@
+// Copyright 2008 The Android Open Source Project
+
+/**
+ * Simple, public base class.
+ */
+public class SimpleBase {
+    public SimpleBase() {}
+}
diff --git a/test/068-classloader/src/Useless.java b/test/068-classloader/src/Useless.java
new file mode 100644 (file)
index 0000000..f51d9a8
--- /dev/null
@@ -0,0 +1,4 @@
+
+public class Useless implements ICommon {
+    public DoubledImplement getDoubledInstance() { return null; }
+}
diff --git a/test/069-field-type/expected.txt b/test/069-field-type/expected.txt
new file mode 100644 (file)
index 0000000..8828178
--- /dev/null
@@ -0,0 +1,4 @@
+Assignment was allowed
+Got expected IncompatibleClassChangeError
+In compareTo
+Done
diff --git a/test/069-field-type/info.txt b/test/069-field-type/info.txt
new file mode 100644 (file)
index 0000000..6e3a22f
--- /dev/null
@@ -0,0 +1,4 @@
+This tests to see if the VM allows you to store a reference to an
+inappropriate object type in an instance field.  By compiling two
+versions of the field-holder class we can bypass the compiler's type
+safety.
diff --git a/test/069-field-type/src/Blah.java b/test/069-field-type/src/Blah.java
new file mode 100644 (file)
index 0000000..fd98336
--- /dev/null
@@ -0,0 +1,9 @@
+
+/**
+ * Trivial class; must implement an interesting interface.
+ */
+public class Blah implements Runnable {
+    public void run() {
+        System.out.println("run");
+    }
+}
diff --git a/test/069-field-type/src/Holder.java b/test/069-field-type/src/Holder.java
new file mode 100644 (file)
index 0000000..e3c9f89
--- /dev/null
@@ -0,0 +1,7 @@
+
+/**
+ * Simple class with one field.
+ */
+public class Holder {
+    public Runnable mValue;
+}
diff --git a/test/069-field-type/src/Main.java b/test/069-field-type/src/Main.java
new file mode 100644 (file)
index 0000000..f9885e6
--- /dev/null
@@ -0,0 +1,34 @@
+
+/**
+ * Create some objects and store them into an instance field.
+ */
+public class Main {
+    /**
+     * Entry point.
+     */
+    public static void main(String[] args) {
+        Holder holder = new Holder();
+
+        Blah blah = new Blah();
+
+        /* strictly speaking, this should fail */
+        holder.mValue = blah;
+
+        System.out.println("Assignment was allowed");
+
+        /* try to use the reference; should fail */
+        try {
+            holder.mValue.run();
+            System.err.println("ERROR: did not get expected ICCE");
+        } catch (IncompatibleClassChangeError icce) {
+            System.out.println("Got expected IncompatibleClassChangeError");
+        }
+
+        /* for fun, verify that it's the "alternate" type */
+        //Comparable cmpx = holder.mValue;      /* compiler rejects */
+        Comparable cmp = (Comparable) holder.mValue;
+        cmp.compareTo(cmp);
+
+        System.out.println("Done");
+    }
+}
diff --git a/test/069-field-type/src2/Blah.java b/test/069-field-type/src2/Blah.java
new file mode 100644 (file)
index 0000000..1bffff6
--- /dev/null
@@ -0,0 +1,10 @@
+
+/**
+ * Trivial class; must implement an interesting interface.
+ */
+public class Blah implements Comparable {
+    public int compareTo(Object another) {
+        System.out.println("In compareTo");
+        return 0;
+    }
+}
diff --git a/test/070-nio-buffer/expected.txt b/test/070-nio-buffer/expected.txt
new file mode 100644 (file)
index 0000000..e271001
--- /dev/null
@@ -0,0 +1,3 @@
+Got expected buffer overflow exception
+Got expected out-of-bounds exception
+Got expected buffer overflow exception
diff --git a/test/070-nio-buffer/info.txt b/test/070-nio-buffer/info.txt
new file mode 100644 (file)
index 0000000..761714e
--- /dev/null
@@ -0,0 +1 @@
+Exercise NIO buffers (e.g. java.nio.ByteBuffer).
diff --git a/test/070-nio-buffer/src/Main.java b/test/070-nio-buffer/src/Main.java
new file mode 100644 (file)
index 0000000..bfcab3a
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.ShortBuffer;
+
+public class Main {
+    public static void main(String[] args) {
+         intFloatTest();
+         basicShortTest();
+    }
+
+    /*
+     * Create a buffer and fiddle with it.
+     */
+    public static void basicShortTest() {
+        ByteBuffer directBuf = ByteBuffer.allocateDirect(64);
+        //ByteBuffer directBuf = ByteBuffer.allocateDirect(65);
+
+        ShortBuffer shortBuf = directBuf.asShortBuffer();
+
+        short[] myShorts = {
+            1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007,
+            1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015,
+            1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023,
+            1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031
+        };
+
+        shortBuf.position(0);
+        shortBuf.put(myShorts, 0, 32);      // should work
+        shortBuf.position(0);
+        shortBuf.put(myShorts, 16, 16);     // should work
+        shortBuf.put(myShorts, 16, 16);     // advance to end
+
+        try {
+            shortBuf.put(myShorts, 0, 1);     // should fail
+            System.err.println("ERROR: out-of-bounds put succeeded\n");
+        } catch (BufferOverflowException boe) {
+            System.out.println("Got expected buffer overflow exception");
+        }
+
+        try {
+            shortBuf.position(0);
+            shortBuf.put(myShorts, 0, 33);     // should fail
+            System.err.println("ERROR: out-of-bounds put succeeded\n");
+        } catch (IndexOutOfBoundsException ioobe) {
+            System.out.println("Got expected out-of-bounds exception");
+        }
+
+        try {
+            shortBuf.position(16);
+            shortBuf.put(myShorts, 0, 17);     // should fail
+            System.err.println("ERROR: out-of-bounds put succeeded\n");
+        } catch (BufferOverflowException boe) {
+            System.out.println("Got expected buffer overflow exception");
+        }
+    }
+
+    /*
+     * Try this with either floats or ints; ints fail with
+     * BufferOverflowException, floats work.
+     *
+     * From http://code.google.com/p/android/issues/detail?id=1585 .
+     */
+    public static void intFloatTest() {
+        ByteBuffer direct = ByteBuffer.allocateDirect(100);
+        direct.order(ByteOrder.nativeOrder());
+        IntBuffer int1 = direct.asIntBuffer();
+        int data[] = new int[25];
+        //FloatBuffer int1 = direct.asFloatBuffer();
+        //float data[] = new float[25];
+        int1.clear ();
+        int1.put (data);
+        int1.position (0);
+
+        int1.clear ();
+        int1.put (data);
+        int1.position (0);
+    }
+}
diff --git a/test/071-dexfile/expected.txt b/test/071-dexfile/expected.txt
new file mode 100644 (file)
index 0000000..b7af75e
--- /dev/null
@@ -0,0 +1,3 @@
+Constructing another
+Got expected ULE
+done
diff --git a/test/071-dexfile/info.txt b/test/071-dexfile/info.txt
new file mode 100644 (file)
index 0000000..54d9ed0
--- /dev/null
@@ -0,0 +1,4 @@
+Exercise some Dalvik-specific DEX file features.  This is not expected to
+work on other VMs.
+
+NOTE: the test requires that /sdcard exists and is writable.
diff --git a/test/071-dexfile/src-ex/Another.java b/test/071-dexfile/src-ex/Another.java
new file mode 100644 (file)
index 0000000..c978c59
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+public class Another {
+    public Another() {
+        System.out.println("Constructing another");
+
+        /* not expected to work; just exercises the call */
+        try {
+            System.loadLibrary("nonexistent");
+        } catch (UnsatisfiedLinkError ule) {
+            System.out.println("Got expected ULE");
+        }
+    }
+}
diff --git a/test/071-dexfile/src/Main.java b/test/071-dexfile/src/Main.java
new file mode 100644 (file)
index 0000000..d71aec0
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+
+/**
+ * DexFile tests (Dalvik-specific).
+ */
+public class Main {
+    private static final String CLASS_PATH = "test-ex.jar";
+    private static final String ODEX_DIR = "/sdcard";
+    //private static final String ODEX_DIR = ".";
+    private static final String ODEX_ALT = "/tmp";
+    private static final String LIB_DIR = "/nowhere/nothing/";
+
+    /**
+     * Prep the environment then run the test.
+     */
+    public static void main(String[] args) {
+        Process p;
+        try {
+            /*
+             * Create a sub-process to see if the ProcessManager wait
+             * interferes with the dexopt invocation wait.
+             *
+             * /dev/random never hits EOF, so we're sure that we'll still
+             * be waiting for the process to complete.  On the device it
+             * stops pretty quickly (which means the child won't be
+             * spinning).
+             */
+            ProcessBuilder pb = new ProcessBuilder("cat", "/dev/random");
+            p = pb.start();
+        } catch (IOException ioe) {
+            System.err.println("cmd failed: " + ioe.getMessage());
+            p = null;
+        }
+
+        try {
+            testDexClassLoader();
+        } finally {
+            // shouldn't be necessary, but it's good to be tidy
+            if (p != null)
+                p.destroy();
+
+            // let the ProcessManager's daemon thread finish before we shut down
+            // (avoids the occasional segmentation fault)
+            try {
+                Thread.sleep(500);
+            } catch (Exception ex) {}
+        }
+
+        System.out.println("done");
+    }
+
+    /**
+     * Create a class loader, explicitly specifying the source DEX and
+     * the location for the optimized DEX.
+     */
+    private static void testDexClassLoader() {
+        ClassLoader dexClassLoader = getDexClassLoader();
+
+        Class anotherClass;
+        try {
+            anotherClass = dexClassLoader.loadClass("Another");
+        } catch (ClassNotFoundException cnfe) {
+            throw new RuntimeException("Another?");
+        }
+
+        Object another;
+        try {
+            another = anotherClass.newInstance();
+        } catch (IllegalAccessException ie) {
+            throw new RuntimeException("new another", ie);
+        } catch (InstantiationException ie) {
+            throw new RuntimeException("new another", ie);
+        }
+
+        // not expected to work; just exercises the call
+        dexClassLoader.getResource("nonexistent");
+    }
+
+    /*
+     * Create an instance of DexClassLoader.  The test harness doesn't
+     * have visibility into dalvik.system.*, so we do this through
+     * reflection.
+     */
+    private static ClassLoader getDexClassLoader() {
+        String odexDir;
+
+        /*
+        String androidData = System.getenv("ANDROID_DATA");
+        if (androidData == null)
+            androidData = "";
+        odexDir = androidData + "/" + ODEX_DIR;
+        */
+
+        File test = new File(ODEX_DIR);
+        if (test.isDirectory())
+            odexDir = ODEX_DIR;
+        else
+            odexDir = ODEX_ALT;
+        //System.out.println("Output dir is " + odexDir);
+
+        ClassLoader myLoader = Main.class.getClassLoader();
+        Class dclClass;
+        try {
+            dclClass = myLoader.loadClass("dalvik.system.DexClassLoader");
+        } catch (ClassNotFoundException cnfe) {
+            throw new RuntimeException("dalvik.system.DexClassLoader not found");
+        }
+
+        Constructor ctor;
+        try {
+            ctor = dclClass.getConstructor(String.class, String.class,
+                String.class, ClassLoader.class);
+        } catch (NoSuchMethodException nsme) {
+            throw new RuntimeException("DCL ctor", nsme);
+        }
+
+        // create an instance, using the path we found
+        Object dclObj;
+        try {
+            dclObj = ctor.newInstance(CLASS_PATH, odexDir, LIB_DIR, myLoader);
+        } catch (Exception ex) {
+            throw new RuntimeException("DCL newInstance", ex);
+        }
+
+        return (ClassLoader) dclObj;
+    }
+}
diff --git a/test/072-precise-gc/expected.txt b/test/072-precise-gc/expected.txt
new file mode 100644 (file)
index 0000000..18ec087
--- /dev/null
@@ -0,0 +1,2 @@
+Valid refs: 0
+String0String1String2String3String4String5String6String7String8String9
diff --git a/test/072-precise-gc/info.txt b/test/072-precise-gc/info.txt
new file mode 100644 (file)
index 0000000..b0b2cea
--- /dev/null
@@ -0,0 +1 @@
+Try to detect whether precise GC is working.
diff --git a/test/072-precise-gc/src/Main.java b/test/072-precise-gc/src/Main.java
new file mode 100644 (file)
index 0000000..e049221
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+import java.lang.ref.WeakReference;
+
+public class Main {
+    public static void main(String[] args) {
+        staleStackTest();
+    }
+
+    public static void staleStackTest() {
+        WeakReference wrefs[] = new WeakReference[10];
+
+        populate(wrefs);
+
+        check(wrefs);
+    }
+
+    static void populate(WeakReference[] wrefs) {
+        /*
+         * Get a bunch of non-constant String objects into registers.  These
+         * should be the first locals declared.
+         */
+        String str0 = generateString("String", 0);
+        String str1 = generateString("String", 1);
+        String str2 = generateString("String", 2);
+        String str3 = generateString("String", 3);
+        String str4 = generateString("String", 4);
+        String str5 = generateString("String", 5);
+        String str6 = generateString("String", 6);
+        String str7 = generateString("String", 7);
+        String str8 = generateString("String", 8);
+        String str9 = generateString("String", 9);
+
+        /* stuff them into the weak references array */
+        wrefs[0] = new WeakReference(str0);
+        wrefs[1] = new WeakReference(str1);
+        wrefs[2] = new WeakReference(str2);
+        wrefs[3] = new WeakReference(str3);
+        wrefs[4] = new WeakReference(str4);
+        wrefs[5] = new WeakReference(str5);
+        wrefs[6] = new WeakReference(str6);
+        wrefs[7] = new WeakReference(str7);
+        wrefs[8] = new WeakReference(str8);
+        wrefs[9] = new WeakReference(str9);
+    }
+
+    static String generateString(String base, int num) {
+        return base + num;
+    }
+
+    static void check(WeakReference[] wrefs) {
+        /*
+         * Declare locals so that our stack overlaps the same region
+         * that populate() did.
+         */
+        String str0;
+        String str1;
+        String str2;
+        String str3;
+        String str4;
+        String str5;
+        String str6;
+        String str7;
+        String str8;
+        String str9;
+        int numValid = 0;
+
+        /*
+         * This *should* blow out all the weakly-reference objects.  If
+         * we still have stale copies of references on the stack, a
+         * conservative GC will try to hold on to those objects and the
+         * count will be nonzero.
+         *
+         * Getting a zero result here isn't conclusive, but it's a strong
+         * indicator that precise GC is having an impact.
+         */
+        System.gc();
+
+        for (int i = 0; i < wrefs.length; i++) {
+            if (wrefs[i].get() != null)
+                numValid++;
+        }
+
+        System.out.println("Valid refs: " + numValid);
+
+        /* use the locals in case the compiler gets smart */
+        str0 = generateString("String", 0);
+        str1 = generateString("String", 1);
+        str2 = generateString("String", 2);
+        str3 = generateString("String", 3);
+        str4 = generateString("String", 4);
+        str5 = generateString("String", 5);
+        str6 = generateString("String", 6);
+        str7 = generateString("String", 7);
+        str8 = generateString("String", 8);
+        str9 = generateString("String", 9);
+        System.out.println(str0+str1+str2+str3+str4+str5+str6+str7+str8+str9);
+    }
+}
diff --git a/test/073-mismatched-field/expected.txt b/test/073-mismatched-field/expected.txt
new file mode 100644 (file)
index 0000000..90fbab8
--- /dev/null
@@ -0,0 +1 @@
+Got expected failure
diff --git a/test/073-mismatched-field/info.txt b/test/073-mismatched-field/info.txt
new file mode 100644 (file)
index 0000000..4a15263
--- /dev/null
@@ -0,0 +1,3 @@
+Test behavior when an instance field is overlapped (through separate
+compilation) by a static field.  The VM is expected to detect the conflict
+and throw an IncompatibleClassChangeError when the field is accessed.
diff --git a/test/073-mismatched-field/src/IMain.java b/test/073-mismatched-field/src/IMain.java
new file mode 100644 (file)
index 0000000..3ad5ecb
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public interface IMain {
+    //static int f = 123;
+}
diff --git a/test/073-mismatched-field/src/Main.java b/test/073-mismatched-field/src/Main.java
new file mode 100644 (file)
index 0000000..70709c0
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Main extends SuperMain implements IMain {
+    public static void main(String[] args) {
+        Main main = new Main();
+        main.doit();
+    }
+
+    void doit() {
+        try {
+            System.out.println("value=" + this.f);
+            System.err.println("Succeeded unexpectedly");
+        } catch (IncompatibleClassChangeError icce) {
+            System.out.println("Got expected failure");
+        }
+    }
+}
diff --git a/test/073-mismatched-field/src/SuperMain.java b/test/073-mismatched-field/src/SuperMain.java
new file mode 100644 (file)
index 0000000..48a9bab
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class SuperMain {
+    public int f = 456;
+}
diff --git a/test/073-mismatched-field/src2/IMain.java b/test/073-mismatched-field/src2/IMain.java
new file mode 100644 (file)
index 0000000..136f2a1
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public interface IMain {
+    static int f = 123;
+}
diff --git a/test/074-gc-thrash/expected.txt b/test/074-gc-thrash/expected.txt
new file mode 100644 (file)
index 0000000..2669165
--- /dev/null
@@ -0,0 +1,2 @@
+Running (10 seconds) ...
+Done.
diff --git a/test/074-gc-thrash/info.txt b/test/074-gc-thrash/info.txt
new file mode 100644 (file)
index 0000000..ded1582
--- /dev/null
@@ -0,0 +1 @@
+This thrashes the memory allocator and garbage collector for a brief period.
diff --git a/test/074-gc-thrash/src/Main.java b/test/074-gc-thrash/src/Main.java
new file mode 100644 (file)
index 0000000..f85aa4b
--- /dev/null
@@ -0,0 +1,337 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+import java.io.File;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+public class Main {
+    public static volatile boolean quit = false;
+    public static final boolean DEBUG = false;
+
+    private static final boolean WRITE_HPROF_DATA = false;
+    private static final int TEST_TIME = 10;
+    private static final String OUTPUT_FILE = "gc-thrash.hprof";
+
+    public static void main(String[] args) {
+        // dump heap before
+
+        System.out.println("Running (" + TEST_TIME + " seconds) ...");
+        runTests();
+
+        Method dumpHprofDataMethod = null;
+        String dumpFile = null;
+
+        if (WRITE_HPROF_DATA) {
+            dumpHprofDataMethod = getDumpHprofDataMethod();
+            if (dumpHprofDataMethod != null) {
+                dumpFile = getDumpFileName();
+                System.out.println("Sending output to " + dumpFile);
+            }
+        }
+
+        System.gc();
+        System.runFinalization();
+        System.gc();
+
+        if (WRITE_HPROF_DATA && dumpHprofDataMethod != null) {
+            try {
+                dumpHprofDataMethod.invoke(null, dumpFile);
+            } catch (IllegalAccessException iae) {
+                System.err.println(iae);
+            } catch (InvocationTargetException ite) {
+                System.err.println(ite);
+            }
+        }
+
+        System.out.println("Done.");
+    }
+
+    /**
+     * Finds VMDebug.dumpHprofData() through reflection.  In the reference
+     * implementation this will not be available.
+     *
+     * @return the reflection object, or null if the method can't be found
+     */
+    private static Method getDumpHprofDataMethod() {
+        ClassLoader myLoader = Main.class.getClassLoader();
+        Class vmdClass;
+        try {
+            vmdClass = myLoader.loadClass("dalvik.system.VMDebug");
+        } catch (ClassNotFoundException cnfe) {
+            return null;
+        }
+
+        Method meth;
+        try {
+            meth = vmdClass.getMethod("dumpHprofData",
+                    new Class[] { String.class });
+        } catch (NoSuchMethodException nsme) {
+            System.err.println("Found VMDebug but not dumpHprofData method");
+            return null;
+        }
+
+        return meth;
+    }
+
+    private static String getDumpFileName() {
+        File tmpDir = new File("/tmp");
+        if (tmpDir.exists() && tmpDir.isDirectory()) {
+            return "/tmp/" + OUTPUT_FILE;
+        }
+
+        File sdcard = new File("/sdcard");
+        if (sdcard.exists() && sdcard.isDirectory()) {
+            return "/sdcard/" + OUTPUT_FILE;
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Run the various tests for a set period.
+     */
+    public static void runTests() {
+        Robin robin = new Robin();
+        Deep deep = new Deep();
+        Large large = new Large();
+
+        /* start all threads */
+        robin.start();
+        deep.start();
+        large.start();
+
+        /* let everybody run for 10 seconds */
+        sleep(TEST_TIME * 1000);
+
+        quit = true;
+
+        try {
+            /* wait for all threads to stop */
+            robin.join();
+            deep.join();
+            large.join();
+        } catch (InterruptedException ie) {
+            System.err.println("join was interrupted");
+        }
+    }
+
+    /**
+     * Sleeps for the "ms" milliseconds.
+     */
+    public static void sleep(int ms) {
+        try {
+            Thread.sleep(ms);
+        } catch (InterruptedException ie) {
+            System.err.println("sleep was interrupted");
+        }
+    }
+
+    /**
+     * Sleeps briefly, allowing other threads some CPU time to get started.
+     */
+    public static void startupDelay() {
+        sleep(500);
+    }
+}
+
+
+/**
+ * Allocates useless objects and holds on to several of them.
+ *
+ * Uses a single large array of references, replaced repeatedly in round-robin
+ * order.
+ */
+class Robin extends Thread {
+    private static final int ARRAY_SIZE = 40960;
+    int sleepCount = 0;
+
+    public void run() {
+        Main.startupDelay();
+
+        String strings[] = new String[ARRAY_SIZE];
+        int idx = 0;
+
+        while (!Main.quit) {
+            strings[idx] = makeString(idx);
+
+            if (idx % (ARRAY_SIZE / 4) == 0) {
+                Main.sleep(400);
+                sleepCount++;
+            }
+
+            idx = (idx + 1) % ARRAY_SIZE;
+        }
+
+        if (Main.DEBUG)
+            System.out.println("Robin: sleepCount=" + sleepCount);
+    }
+
+    private String makeString(int val) {
+        return new String("Robin" + val);
+    }
+}
+
+
+/**
+ * Allocates useless objects in recursive calls.
+ */
+class Deep extends Thread {
+    private static final int MAX_DEPTH = 61;
+
+    private static String strong[] = new String[MAX_DEPTH];
+    private static WeakReference weak[] = new WeakReference[MAX_DEPTH];
+
+    public void run() {
+        int iter = 0;
+        boolean once = false;
+
+        Main.startupDelay();
+
+        while (!Main.quit) {
+            dive(0, iter);
+            once = true;
+            iter += MAX_DEPTH;
+        }
+
+        if (!once) {
+            System.err.println("not even once?");
+            return;
+        }
+
+        /*
+         * Check the results of the last trip through.  Everything in
+         * "weak" should be matched in "strong", and the two should be
+         * equivalent (object-wise, not just string-equality-wise).
+         */
+        for (int i = 0; i < MAX_DEPTH; i++) {
+            if (strong[i] != weak[i].get()) {
+                System.err.println("Deep: " + i + " strong=" + strong[i] +
+                    ", weak=" + weak[i].get());
+            }
+        }
+
+        /*
+         * Wipe "strong", do a GC, see if "weak" got collected.
+         */
+        for (int i = 0; i < MAX_DEPTH; i++)
+            strong[i] = null;
+
+        System.gc();
+
+        for (int i = 0; i < MAX_DEPTH; i++) {
+            if (weak[i].get() != null) {
+                System.err.println("Deep: weak still has " + i);
+            }
+        }
+
+        if (Main.DEBUG)
+            System.out.println("Deep: iters=" + iter / MAX_DEPTH);
+    }
+
+    /**
+     * Recursively dive down, setting one or more local variables.
+     *
+     * We pad the stack out with locals, attempting to create a mix of
+     * valid and invalid references on the stack.
+     */
+    private String dive(int depth, int iteration) {
+        String str0;
+        String str1;
+        String str2;
+        String str3;
+        String str4;
+        String str5;
+        String str6;
+        String str7;
+        String funStr;
+
+        funStr = "";
+
+        switch (iteration % 8) {
+            case 0:
+                funStr = str0 = makeString(iteration);
+                break;
+            case 1:
+                funStr = str1 = makeString(iteration);
+                break;
+            case 2:
+                funStr = str2 = makeString(iteration);
+                break;
+            case 3:
+                funStr = str3 = makeString(iteration);
+                break;
+            case 4:
+                funStr = str4 = makeString(iteration);
+                break;
+            case 5:
+                funStr = str5 = makeString(iteration);
+                break;
+            case 6:
+                funStr = str6 = makeString(iteration);
+                break;
+            case 7:
+                funStr = str7 = makeString(iteration);
+                break;
+        }
+
+        strong[depth] = funStr;
+        weak[depth] = new WeakReference(funStr);
+
+        if (depth+1 < MAX_DEPTH)
+            dive(depth+1, iteration+1);
+        else
+            Main.sleep(100);
+
+        return funStr;
+    }
+
+    private String makeString(int val) {
+        return new String("Deep" + val);
+    }
+}
+
+
+/**
+ * Allocates large useless objects.
+ */
+class Large extends Thread {
+    public void run() {
+        byte[] chunk;
+        int count = 0;
+        int sleepCount = 0;
+
+        Main.startupDelay();
+
+        while (!Main.quit) {
+            chunk = new byte[100000];
+            pretendToUse(chunk);
+
+            count++;
+            if ((count % 500) == 0) {
+                Main.sleep(400);
+                sleepCount++;
+            }
+        }
+
+        if (Main.DEBUG)
+            System.out.println("Large: sleepCount=" + sleepCount);
+    }
+
+    public void pretendToUse(byte[] chunk) {}
+}
diff --git a/test/075-verification-error/expected.txt b/test/075-verification-error/expected.txt
new file mode 100644 (file)
index 0000000..6e4f584
--- /dev/null
@@ -0,0 +1,12 @@
+Got expected InstantationError
+Got expected NoSuchFieldError
+Got expected NoSuchFieldError
+Got expected NoSuchMethodError
+Got expected NoSuchMethodError
+Got expected IllegalAccessError (ifield)
+Got expected IllegalAccessError (sfield)
+Got expected IllegalAccessError (method)
+Got expected IllegalAccessError (smethod)
+Got expected IllegalAccessError (meth-class)
+Got expected IllegalAccessError (field-class)
+Got expected IllegalAccessError (meth-meth)
diff --git a/test/075-verification-error/info.txt b/test/075-verification-error/info.txt
new file mode 100644 (file)
index 0000000..be688ff
--- /dev/null
@@ -0,0 +1 @@
+Exercise deferred verification error reporting.
diff --git a/test/075-verification-error/src/Main.java b/test/075-verification-error/src/Main.java
new file mode 100644 (file)
index 0000000..51d648c
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+import other.Mutant;
+import other.InaccessibleClass;
+import other.InaccessibleMethod;
+
+/**
+ * Test some problematic situations that the verifier detects.
+ */
+public class Main {
+    public static final boolean VERBOSE = false;
+
+    public static void main(String[] args) {
+        testClassNewInstance();
+        testMissingStuff();
+        testBadAccess();
+    }
+
+    /**
+     * Try to create a new instance of an abstract class.
+     */
+    static void testClassNewInstance() {
+        try {
+            MaybeAbstract ma = new MaybeAbstract();
+            System.err.println("ERROR: MaybeAbstract succeeded unexpectedly");
+        } catch (InstantiationError ie) {
+            System.out.println("Got expected InstantationError");
+            if (VERBOSE) System.out.println("--- " + ie);
+        } catch (Exception ex) {
+            System.err.println("Got unexpected MaybeAbstract failure");
+        }
+    }
+
+    /**
+     * Test stuff that disappears.
+     */
+    static void testMissingStuff() {
+        Mutant mutant = new Mutant();
+
+        try {
+            int x = mutant.disappearingField;
+        } catch (NoSuchFieldError nsfe) {
+            System.out.println("Got expected NoSuchFieldError");
+            if (VERBOSE) System.out.println("--- " + nsfe);
+        }
+
+        try {
+            int y = Mutant.disappearingStaticField;
+        } catch (NoSuchFieldError nsfe) {
+            System.out.println("Got expected NoSuchFieldError");
+            if (VERBOSE) System.out.println("--- " + nsfe);
+        }
+
+        try {
+            mutant.disappearingMethod();
+        } catch (NoSuchMethodError nsme) {
+            System.out.println("Got expected NoSuchMethodError");
+            if (VERBOSE) System.out.println("--- " + nsme);
+        }
+
+        try {
+            Mutant.disappearingStaticMethod();
+        } catch (NoSuchMethodError nsme) {
+            System.out.println("Got expected NoSuchMethodError");
+            if (VERBOSE) System.out.println("--- " + nsme);
+        }
+    }
+
+    /**
+     * Test stuff that becomes inaccessible.
+     */
+    static void testBadAccess() {
+        Mutant mutant = new Mutant();
+
+        try {
+            int x = mutant.inaccessibleField;
+            System.err.println("ERROR: bad access succeeded\n");
+        } catch (IllegalAccessError iae) {
+            System.out.println("Got expected IllegalAccessError (ifield)");
+            if (VERBOSE) System.out.println("--- " + iae);
+        }
+
+        try {
+            int y = Mutant.inaccessibleStaticField;
+            System.err.println("ERROR: bad access succeeded\n");
+        } catch (IllegalAccessError iae) {
+            System.out.println("Got expected IllegalAccessError (sfield)");
+            if (VERBOSE) System.out.println("--- " + iae);
+        }
+
+        try {
+            mutant.inaccessibleMethod();
+            System.err.println("ERROR: bad access succeeded\n");
+        } catch (IllegalAccessError iae) {
+            System.out.println("Got expected IllegalAccessError (method)");
+            if (VERBOSE) System.out.println("--- " + iae);
+        }
+
+        try {
+            Mutant.inaccessibleStaticMethod();
+            System.err.println("ERROR: bad access succeeded\n");
+        } catch (IllegalAccessError iae) {
+            System.out.println("Got expected IllegalAccessError (smethod)");
+            if (VERBOSE) System.out.println("--- " + iae);
+        }
+
+        try {
+            /* accessible static method in an inaccessible class */
+            InaccessibleClass.test();
+            System.err.println("ERROR: bad meth-class access succeeded\n");
+        } catch (IllegalAccessError iae) {
+            System.out.println("Got expected IllegalAccessError (meth-class)");
+            if (VERBOSE) System.out.println("--- " + iae);
+        }
+
+        try {
+            /* accessible static field in an inaccessible class */
+            int blah = InaccessibleClass.blah;
+            System.err.println("ERROR: bad field-class access succeeded\n");
+        } catch (IllegalAccessError iae) {
+            System.out.println("Got expected IllegalAccessError (field-class)");
+            if (VERBOSE) System.out.println("--- " + iae);
+        }
+
+        try {
+            /* inaccessible static method in an accessible class */
+            InaccessibleMethod.test();
+            System.err.println("ERROR: bad access succeeded\n");
+        } catch (IllegalAccessError iae) {
+            System.out.println("Got expected IllegalAccessError (meth-meth)");
+            if (VERBOSE) System.out.println("--- " + iae);
+        }
+    }
+}
diff --git a/test/075-verification-error/src/MaybeAbstract.java b/test/075-verification-error/src/MaybeAbstract.java
new file mode 100644 (file)
index 0000000..6d3b05b
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public /*abstract*/ class MaybeAbstract {
+    public MaybeAbstract() {}
+    int foo() { return 0; }
+}
diff --git a/test/075-verification-error/src/other/InaccessibleClass.java b/test/075-verification-error/src/other/InaccessibleClass.java
new file mode 100644 (file)
index 0000000..b9bdfc4
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2009 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 other;
+
+public class InaccessibleClass {
+    public static void test() {}
+
+    public static int blah = 5;
+}
diff --git a/test/075-verification-error/src/other/InaccessibleMethod.java b/test/075-verification-error/src/other/InaccessibleMethod.java
new file mode 100644 (file)
index 0000000..0460373
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2009 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 other;
+
+public class InaccessibleMethod {
+    public static void test() {}
+}
diff --git a/test/075-verification-error/src/other/Mutant.java b/test/075-verification-error/src/other/Mutant.java
new file mode 100644 (file)
index 0000000..ec4754b
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2009 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 other;
+
+/**
+ * Parts of this class will disappear or change form.
+ */
+public class Mutant {
+    public int disappearingField = 3;
+    public static int disappearingStaticField = 4;
+
+    public void disappearingMethod() {
+        System.out.println("bye");
+    }
+    public static void disappearingStaticMethod() {
+        System.out.println("kthxbai");
+    }
+
+    public int inaccessibleField = 5;
+    public static int inaccessibleStaticField = 6;
+
+    public void inaccessibleMethod() {
+        System.out.println("no");
+    }
+
+    public static void inaccessibleStaticMethod() {
+        System.out.println("nay");
+    }
+}
diff --git a/test/075-verification-error/src2/MaybeAbstract.java b/test/075-verification-error/src2/MaybeAbstract.java
new file mode 100644 (file)
index 0000000..8b70a07
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public abstract class MaybeAbstract {
+    public MaybeAbstract() {}
+    int foo() { return 0; }
+}
diff --git a/test/075-verification-error/src2/other/InaccessibleClass.java b/test/075-verification-error/src2/other/InaccessibleClass.java
new file mode 100644 (file)
index 0000000..812fac9
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2009 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 other;
+
+/*package*/ class InaccessibleClass {
+    public static void test() {}
+
+    public static int blah = 5;
+}
diff --git a/test/075-verification-error/src2/other/InaccessibleMethod.java b/test/075-verification-error/src2/other/InaccessibleMethod.java
new file mode 100644 (file)
index 0000000..9fb844e
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2009 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 other;
+
+public class InaccessibleMethod {
+    /*package*/ static void test() {}
+}
diff --git a/test/075-verification-error/src2/other/Mutant.java b/test/075-verification-error/src2/other/Mutant.java
new file mode 100644 (file)
index 0000000..67cd36d
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2009 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 other;
+
+/**
+ * Parts of this class will disappear or change form.
+ */
+public class Mutant {
+    //public int disappearingField = 3;
+    //public static int disappearingStaticField = 4;
+
+    //public static void disappearingMethod() {
+    //    System.out.println("bye");
+    //}
+    //public static void disappearingStaticMethod() {
+    //    System.out.println("kthxbai");
+    //}
+
+    protected int inaccessibleField = 5;
+    protected static int inaccessibleStaticField = 6;
+
+    protected void inaccessibleMethod() {
+        System.out.println("no");
+    }
+
+    protected static void inaccessibleStaticMethod() {
+        System.out.println("nay");
+    }
+}
diff --git a/test/076-boolean-put/expected.txt b/test/076-boolean-put/expected.txt
new file mode 100644 (file)
index 0000000..a965a70
--- /dev/null
@@ -0,0 +1 @@
+Done
diff --git a/test/076-boolean-put/info.txt b/test/076-boolean-put/info.txt
new file mode 100644 (file)
index 0000000..5b3ef4d
--- /dev/null
@@ -0,0 +1,3 @@
+This checks a case where javac generates code that stores a byte into a
+boolean field.  The code as generated should not pass the verifier, so the
+verifier had to be "loosened" to allow this case.
diff --git a/test/076-boolean-put/src/Main.java b/test/076-boolean-put/src/Main.java
new file mode 100644 (file)
index 0000000..b325422
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+/**
+ * Test access to private boolean fields.
+ *
+ * Accessing private boolean fields from an inner class causes the compiler
+ * to generate an accessor method that performs the boolean operation.
+ * Unfortunately the generated method takes an integer as an argument,
+ * not a boolean, which makes the verifier upset when the result of the
+ * operation is written back to a boolean field.
+ */
+public class Main {
+    private boolean mInstance;
+    private static boolean mStatic;
+
+    public static void main(String[] args) {
+        Main foo = new Main();
+        foo.test();
+
+        System.out.println("Done");
+    }
+
+    void test() {
+        Innard innard = new Innard();
+        innard.doStuff();
+    }
+
+    class Innard {
+        void doStuff() {
+            mInstance |= true;
+            mStatic |= true;
+        }
+    }
+}
diff --git a/test/077-method-override/expected.txt b/test/077-method-override/expected.txt
new file mode 100644 (file)
index 0000000..2e9bda3
--- /dev/null
@@ -0,0 +1,15 @@
+declaredInBase: Base
+notDeclaredInBase: Derived
+wasOverridden: Derived
+overrideWithPublic: Derived
+overrideProtectedWithPublic: Derived
+overridePublicWithProtected: Derived
+overridePublicWithPrivate: Base
+overridePrivateWithPublic: Base
+overridePrivateWithPublic: Derived
+overrideVirtualWithStatic: Base
+overrideVirtualWithStatic: Derived
+overrideStaticWithVirtual: Base
+overrideStaticWithVirtual: Derived
+Got expected exception - ovws
+Got expected exception - oswv
diff --git a/test/077-method-override/info.txt b/test/077-method-override/info.txt
new file mode 100644 (file)
index 0000000..914b4f2
--- /dev/null
@@ -0,0 +1,2 @@
+Test various forms of method overrides, including some not allowed by the
+compiler but possible with separate compilation.
diff --git a/test/077-method-override/src/Base.java b/test/077-method-override/src/Base.java
new file mode 100644 (file)
index 0000000..befe2e2
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Base {
+    public void declaredInBase() {
+        System.out.println("declaredInBase: Base");
+    }
+
+    public void overridden() {
+        System.out.println("overridden: Base");
+    }
+
+    /* src2: removed */
+    public void wasOverridden() {
+        System.out.println("wasOverridden: Base");
+    }
+
+    public void callOverrideWithPublic() {
+        overrideWithPublic();
+    }
+    public void overrideWithPublic() {
+        System.out.println("overrideWithPublic: Base");
+    }
+
+    public void callOverridePublicWithProtected() {
+        overridePublicWithProtected();
+    }
+    /* src2: public */
+    protected void overridePublicWithProtected() {
+        System.out.println("overridePublicWithProtected: Base");
+    }
+
+    public void callOverrideProtectedWithPublic() {
+        overrideProtectedWithPublic();
+    }
+    protected void overrideProtectedWithPublic() {
+        System.out.println("overrideProtectedWithPublic: Base");
+    }
+
+    public void callOverridePublicWithPrivate() {
+        overridePublicWithPrivate();
+    }
+    /* src2: public */
+    private void overridePublicWithPrivate() {
+        System.out.println("overridePublicWithPrivate: Base");
+    }
+
+    public void callOverridePrivateWithPublic() {
+        overridePrivateWithPublic();
+    }
+    private void overridePrivateWithPublic() {
+        System.out.println("overridePrivateWithPublic: Base");
+    }
+
+    public void callOverrideVirtualWithStatic() {
+        overrideVirtualWithStatic();
+    }
+    /* src2: non-static */
+    public static void overrideVirtualWithStatic() {
+        System.out.println("overrideVirtualWithStatic: Base");
+    }
+
+    public void callOverrideStaticWithVirtual() {
+        overrideStaticWithVirtual();
+    }
+    /* src2: static */
+    public void overrideStaticWithVirtual() {
+        System.out.println("overrideStaticWithVirtual: Base");
+    }
+}
diff --git a/test/077-method-override/src/Derived.java b/test/077-method-override/src/Derived.java
new file mode 100644 (file)
index 0000000..7dc43d0
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Derived extends Base {
+    public static void notDeclaredInBase() {
+        System.out.println("notDeclaredInBase: Derived");
+    }
+
+    public void overridden() {
+        System.out.println("overridden: Derived");
+    }
+
+    public void wasOverridden() {
+        System.out.println("wasOverridden: Derived");
+    }
+
+    public void overrideWithPublic() {
+        System.out.println("overrideWithPublic: Derived");
+    }
+
+    protected void overridePublicWithProtected() {
+        System.out.println("overridePublicWithProtected: Derived");
+    }
+
+    public void overrideProtectedWithPublic() {
+        System.out.println("overrideProtectedWithPublic: Derived");
+    }
+
+    private void overridePublicWithPrivate() {
+        System.out.println("overridePublicWithPrivate: Derived");
+    }
+
+    public void overridePrivateWithPublic() {
+        System.out.println("overridePrivateWithPublic: Derived");
+    }
+
+    /* not really an "override"; just has same method signature */
+    public static void overrideVirtualWithStatic() {
+        System.out.println("overrideVirtualWithStatic: Derived");
+    }
+
+    /* not really an "override"; just has same method signature */
+    public void overrideStaticWithVirtual() {
+        System.out.println("overrideStaticWithVirtual: Derived");
+    }
+}
diff --git a/test/077-method-override/src/Main.java b/test/077-method-override/src/Main.java
new file mode 100644 (file)
index 0000000..2d10ee0
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Main {
+    public static void main(String args[]) {
+        Derived derived = new Derived();
+
+        derived.declaredInBase();
+        derived.notDeclaredInBase();
+        derived.wasOverridden();
+
+        derived.callOverrideWithPublic();
+        derived.callOverrideProtectedWithPublic();
+        derived.callOverridePublicWithProtected();
+        derived.callOverridePublicWithPrivate();
+        derived.callOverridePrivateWithPublic();
+        derived.overridePrivateWithPublic();
+        derived.callOverrideVirtualWithStatic();
+        derived.overrideVirtualWithStatic();
+        derived.callOverrideStaticWithVirtual();
+        derived.overrideStaticWithVirtual();
+
+        try {
+            ((Base)derived).overrideVirtualWithStatic();
+        } catch (NoSuchMethodError nsme) {
+            /* NSME is subclass of ICCE, so check it explicitly */
+            System.err.println("Got NSME - ovws");
+        } catch (IncompatibleClassChangeError icce) {
+            System.out.println("Got expected exception - ovws");
+        }
+
+        try {
+            ((Base)derived).overrideStaticWithVirtual();
+        } catch (NoSuchMethodError nsme) {
+            System.err.println("Got NSME - ovws");
+        } catch (IncompatibleClassChangeError icce) {
+            System.out.println("Got expected exception - oswv");
+        }
+    }
+}
diff --git a/test/077-method-override/src2/Base.java b/test/077-method-override/src2/Base.java
new file mode 100644 (file)
index 0000000..ab2a28b
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Base {
+    public void declaredInBase() {
+        System.out.println("declaredInBase: Base");
+    }
+
+    public void overridden() {
+        System.out.println("overridden: Base");
+    }
+
+    /* src2: removed */
+    //public void wasOverridden() {
+    //    System.out.println("wasOverridden: Base");
+    //}
+
+    public void callOverrideWithPublic() {
+        overrideWithPublic();
+    }
+    public void overrideWithPublic() {
+        System.out.println("overrideWithPublic: Base");
+    }
+
+    public void callOverridePublicWithProtected() {
+        overridePublicWithProtected();
+    }
+    /* src2: public */
+    public void overridePublicWithProtected() {
+        System.out.println("overridePublicWithProtected: Base");
+    }
+
+    public void callOverrideProtectedWithPublic() {
+        overrideProtectedWithPublic();
+    }
+    protected void overrideProtectedWithPublic() {
+        System.out.println("overrideProtectedWithPublic: Base");
+    }
+
+    public void callOverridePublicWithPrivate() {
+        overridePublicWithPrivate();
+    }
+    /* src2: public */
+    public void overridePublicWithPrivate() {
+        System.out.println("overridePublicWithPrivate: Base");
+    }
+
+    public void callOverridePrivateWithPublic() {
+        overridePrivateWithPublic();
+    }
+    private void overridePrivateWithPublic() {
+        System.out.println("overridePrivateWithPublic: Base");
+    }
+
+    public void callOverrideVirtualWithStatic() {
+        overrideVirtualWithStatic();
+    }
+    /* src2: non-static */
+    public void overrideVirtualWithStatic() {
+        System.out.println("overrideVirtualWithStatic: Base");
+    }
+
+    public void callOverrideStaticWithVirtual() {
+        overrideStaticWithVirtual();
+    }
+    public static void overrideStaticWithVirtual() {
+        System.out.println("overrideStaticWithVirtual: Base");
+    }
+}
diff --git a/test/078-polymorphic-virtual/expected.txt b/test/078-polymorphic-virtual/expected.txt
new file mode 100644 (file)
index 0000000..0d29728
--- /dev/null
@@ -0,0 +1,3 @@
+10000000
+20000000
+30000000
diff --git a/test/078-polymorphic-virtual/info.txt b/test/078-polymorphic-virtual/info.txt
new file mode 100644 (file)
index 0000000..7c8a561
--- /dev/null
@@ -0,0 +1,2 @@
+Stress test predicted chaining for overloaded virtual callsite with 3 resolved
+calless invoked 10,000,000 times each in three threads.
diff --git a/test/078-polymorphic-virtual/src/Base.java b/test/078-polymorphic-virtual/src/Base.java
new file mode 100644 (file)
index 0000000..ec3aadd
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Base extends Thread {
+    int value;
+
+    public void run() {
+        for (int i = 0; i < 10000000; i++) {
+            incrimentValue();
+        }
+    }
+
+    public void incrimentValue() {
+    }
+
+    public int getValue() {
+        return value;
+    }
+}
diff --git a/test/078-polymorphic-virtual/src/Derived1.java b/test/078-polymorphic-virtual/src/Derived1.java
new file mode 100644 (file)
index 0000000..57bd3b0
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Derived1 extends Base {
+    public void incrimentValue() {
+        value += 1;
+    }
+}
diff --git a/test/078-polymorphic-virtual/src/Derived2.java b/test/078-polymorphic-virtual/src/Derived2.java
new file mode 100644 (file)
index 0000000..1d7de57
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Derived2 extends Base {
+    public void incrimentValue() {
+        value += 2;
+    }
+}
diff --git a/test/078-polymorphic-virtual/src/Derived3.java b/test/078-polymorphic-virtual/src/Derived3.java
new file mode 100644 (file)
index 0000000..c2594d2
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Derived3 extends Base {
+    public void incrimentValue() {
+        value += 3;
+    }
+}
diff --git a/test/078-polymorphic-virtual/src/Main.java b/test/078-polymorphic-virtual/src/Main.java
new file mode 100644 (file)
index 0000000..0514e53
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Main {
+    public static void main(String args[]) {
+        Derived1 derived1 = new Derived1();
+        Derived2 derived2 = new Derived2();
+        Derived3 derived3 = new Derived3();
+
+        derived1.start();
+        derived2.start();
+        derived3.start();
+
+        try {
+            derived1.join();
+            derived2.join();
+            derived3.join();
+        } catch (Exception e) {
+            System.out.println(e);
+            return;
+        }
+
+        System.out.println(derived1.getValue());
+        System.out.println(derived2.getValue());
+        System.out.println(derived3.getValue());
+    }
+}
diff --git a/test/079-phantom/expected.txt b/test/079-phantom/expected.txt
new file mode 100644 (file)
index 0000000..a932b77
--- /dev/null
@@ -0,0 +1,14 @@
+start
+Created Bitmap one: 10x10 (100)
+Created Bitmap two: 20x20 (101)
+Created Bitmap three/four: 20x20 (101)
+Drawing Bitmap two: 20x20 (101)
+nulling 1
+freeNativeStorage: 100
+nulling 2
+nulling 3
+nulling 4
+freeNativeStorage: 101
+intr
+Bitmap has shut down
+done
diff --git a/test/079-phantom/info.txt b/test/079-phantom/info.txt
new file mode 100644 (file)
index 0000000..d974e2c
--- /dev/null
@@ -0,0 +1 @@
+Exercise phantom references.
diff --git a/test/079-phantom/src/Bitmap.java b/test/079-phantom/src/Bitmap.java
new file mode 100644 (file)
index 0000000..9d03cbd
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.PhantomReference;
+import java.util.ArrayList;
+
+public class Bitmap {
+    String mName;           /* for debugging */
+    int mWidth, mHeight;
+    Bitmap.NativeWrapper mNativeWrapper;
+
+    private static int sSerial = 100;
+    private static ArrayList sPhantomList = new ArrayList<PhantomWrapper>();
+    private static ReferenceQueue<PhantomWrapper> sPhantomQueue =
+            new ReferenceQueue<PhantomWrapper>();
+    private static BitmapWatcher sWatcher = new BitmapWatcher(sPhantomQueue);
+    static {
+        sWatcher.start();
+    };
+
+    Bitmap(String name, int width, int height, Bitmap.NativeWrapper nativeData) {
+        mName = name;
+        mWidth = width;
+        mHeight = height;
+        mNativeWrapper = nativeData;
+
+        System.out.println("Created " + this);
+    }
+
+    public String toString() {
+        return "Bitmap " + mName + ": " + mWidth + "x" + mHeight + " (" +
+                mNativeWrapper.mNativeData + ")";
+    }
+
+    public void drawAt(int x, int y) {
+        System.out.println("Drawing " + this);
+    }
+
+    public static void shutDown() {
+        sWatcher.shutDown();
+        try {
+            sWatcher.join();
+        } catch (InterruptedException ie) {
+            System.out.println("join intr");
+        }
+        System.out.println("Bitmap has shut down");
+    }
+
+    /*
+     * Pretend we're allocating native storage.  Just returns a unique
+     * serial number.
+     */
+    static Bitmap.NativeWrapper allocNativeStorage(int width, int height) {
+        int nativeData;
+
+        synchronized (Bitmap.class) {
+            nativeData = sSerial++;
+        }
+
+        Bitmap.NativeWrapper wrapper = new Bitmap.NativeWrapper(nativeData);
+        PhantomWrapper phan = new PhantomWrapper(wrapper, sPhantomQueue,
+                nativeData);
+        sPhantomList.add(phan);
+        return wrapper;
+    }
+
+    static void freeNativeStorage(int nativeDataPtr) {
+        System.out.println("freeNativeStorage: " + nativeDataPtr);
+    }
+
+    /*
+     * Wraps a native data pointer in an object.  When this object is no
+     * longer referenced, we free the native data.
+     */
+    static class NativeWrapper {
+        public NativeWrapper(int nativeDataPtr) {
+            mNativeData = nativeDataPtr;
+        }
+        public int mNativeData;
+
+        /*
+        @Override
+        protected void finalize() throws Throwable {
+            System.out.println("finalized " + mNativeData);
+        }
+        */
+    }
+}
+
+/*
+ * Keep an eye on the native data.
+ *
+ * We keep a copy of the native data pointer value, and set the wrapper
+ * as our referent.  We need the copy because you can't get the referred-to
+ * object back out of a PhantomReference.
+ */
+class PhantomWrapper extends PhantomReference {
+    PhantomWrapper(Bitmap.NativeWrapper wrapper,
+        ReferenceQueue<PhantomWrapper> queue, int nativeDataPtr)
+    {
+        super(wrapper, queue);
+        mNativeData = nativeDataPtr;
+    }
+
+    public int mNativeData;
+}
+
+/*
+ * Thread that watches for un-referenced bitmap data.
+ */
+class BitmapWatcher extends Thread {
+    ReferenceQueue<PhantomWrapper> mQueue;
+    volatile boolean mQuit = false;
+
+    BitmapWatcher(ReferenceQueue<PhantomWrapper> queue) {
+        mQueue = queue;
+        setName("Bitmap Watcher");
+    }
+
+    public void run() {
+        while (!mQuit) {
+            try {
+                PhantomWrapper ref = (PhantomWrapper) mQueue.remove();
+                //System.out.println("dequeued ref " + ref.mNativeData +
+                //    " - " + ref);
+                Bitmap.freeNativeStorage(ref.mNativeData);
+                //ref.clear();
+            } catch (InterruptedException ie) {
+                System.out.println("intr");
+            }
+        }
+    }
+
+    public void shutDown() {
+        mQuit = true;
+        interrupt();
+    }
+}
diff --git a/test/079-phantom/src/Main.java b/test/079-phantom/src/Main.java
new file mode 100644 (file)
index 0000000..9c459c9
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Main {
+    Bitmap mBitmap1, mBitmap2, mBitmap3, mBitmap4;
+
+    public static void sleep(int ms) {
+        try {
+            Thread.sleep(ms);
+        } catch (InterruptedException ie) {
+            System.err.println("sleep interrupted");
+        }
+    }
+
+    public static void main(String args[]) {
+        System.out.println("start");
+
+        Main main = new Main();
+        main.run();
+
+        sleep(1000);
+        System.out.println("done");
+    }
+
+    public void run() {
+        createBitmaps();
+
+        System.gc();
+        sleep(250);
+
+        mBitmap2.drawAt(0, 0);
+
+        System.out.println("nulling 1");
+        mBitmap1 = null;
+        System.gc();
+        sleep(500);
+
+        System.out.println("nulling 2");
+        mBitmap2 = null;
+        System.gc();
+        sleep(500);
+
+        System.out.println("nulling 3");
+        mBitmap3 = null;
+        System.gc();
+        sleep(500);
+
+        System.out.println("nulling 4");
+        mBitmap4 = null;
+        System.gc();
+        sleep(500);
+
+        Bitmap.shutDown();
+    }
+
+    /*
+     * Create bitmaps.
+     *
+     * bitmap1 is 10x10 and unique
+     * bitmap2 and bitmap3 are 20x20 and share the same storage.
+     * bitmap4 is just another reference to bitmap3
+     *
+     * When we return there should be no local refs lurking on the stack.
+     */
+    public void createBitmaps() {
+        Bitmap.NativeWrapper dataA = Bitmap.allocNativeStorage(10, 10);
+        Bitmap.NativeWrapper dataB = Bitmap.allocNativeStorage(20, 20);
+        mBitmap1 = new Bitmap("one", 10, 10, dataA);
+        mBitmap2 = new Bitmap("two", 20, 20, dataB);
+        mBitmap3 = mBitmap4 = new Bitmap("three/four", 20, 20, dataB);
+    }
+}
diff --git a/test/080-oom-throw/expected.txt b/test/080-oom-throw/expected.txt
new file mode 100644 (file)
index 0000000..811f68c
--- /dev/null
@@ -0,0 +1,2 @@
+Array allocation failed
+Instance allocation failed
diff --git a/test/080-oom-throw/info.txt b/test/080-oom-throw/info.txt
new file mode 100644 (file)
index 0000000..e8ae6f6
--- /dev/null
@@ -0,0 +1,3 @@
+Inject memory allocation failures for NEW_ARRAY and NEW_INSTANCE and make sure
+the JIT'ed code handles OOM exception correctly since it cannot fall back to
+the interpreter and re-execute the bytecode.
diff --git a/test/080-oom-throw/src/Main.java b/test/080-oom-throw/src/Main.java
new file mode 100644 (file)
index 0000000..3d75f3d
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Main {
+    static class ArrayMemEater {
+        static int blowup(char[][] holder, int size) {
+            int i = 0;
+            try {
+                for ( ; i < size; i++)
+                    holder[i] = new char[128];
+            } catch (OutOfMemoryError oome) {
+                return i;
+            }
+
+            return size;
+        }
+
+        static void confuseCompilerOptimization(char[][] holder) {
+        }
+    }
+
+    static class InstanceMemEater {
+        InstanceMemEater next;
+        double d1, d2, d3, d4, d5, d6, d7, d8;
+
+        static InstanceMemEater blowup() {
+            InstanceMemEater memEater;
+            try {
+                memEater = new InstanceMemEater();
+            } catch (OutOfMemoryError e) {
+                memEater = null;
+            }
+            return memEater;
+        }
+
+        static void confuseCompilerOptimization(InstanceMemEater memEater) {
+        }
+    }
+
+    static void triggerArrayOOM() {
+        int size = 1 * 1024 * 1024;
+        char[][] holder = new char[size][];
+
+        int count = ArrayMemEater.blowup(holder, size);
+        ArrayMemEater.confuseCompilerOptimization(holder);
+        if (count < size) {
+            System.out.println("Array allocation failed");
+        }
+    }
+
+    static void triggerInstanceOOM() {
+        InstanceMemEater memEater = InstanceMemEater.blowup();
+        InstanceMemEater lastMemEater = memEater;
+        do {
+            lastMemEater.next = InstanceMemEater.blowup();
+            lastMemEater = lastMemEater.next;
+        } while (lastMemEater != null);
+        memEater.confuseCompilerOptimization(memEater);
+        System.out.println("Instance allocation failed");
+    }
+
+    public static void main(String[] args) {
+        triggerArrayOOM();
+        triggerInstanceOOM();
+    }
+}
diff --git a/test/081-hot-exceptions/expected.txt b/test/081-hot-exceptions/expected.txt
new file mode 100644 (file)
index 0000000..2432ff4
--- /dev/null
@@ -0,0 +1,2 @@
+sum = 0
+exception = 1024
diff --git a/test/081-hot-exceptions/info.txt b/test/081-hot-exceptions/info.txt
new file mode 100644 (file)
index 0000000..cc514f3
--- /dev/null
@@ -0,0 +1,3 @@
+Make a hot exception-throwing path to stress test how the trace builder handles
+exceptions encountered during trace selection. The existence of exceptions will
+cause a control flow change to deviate from the current method.
diff --git a/test/081-hot-exceptions/src/Main.java b/test/081-hot-exceptions/src/Main.java
new file mode 100644 (file)
index 0000000..90e7af2
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+public class Main {
+    static class ArrayObj {
+        int[] array;
+
+        int getArrayElement(int i) throws NullPointerException {
+            return array[i];
+        }
+    }
+
+    public static void main(String[] args) {
+        ArrayObj arrayObj2 = new ArrayObj();
+        int sum = 0;
+        int exception = 0;
+
+        for (int i = 0; i < 1024; i++) {
+            try {
+                // A hot method invocation that always encounters exceptions
+                sum += arrayObj2.getArrayElement(i);
+            } catch (NullPointerException npe) {
+                exception++;
+            }
+        }
+        System.out.println("sum = " + sum);
+        System.out.println("exception = " + exception);
+    }
+}
diff --git a/test/082-inline-execute/expected.txt b/test/082-inline-execute/expected.txt
new file mode 100644 (file)
index 0000000..5059fe8
--- /dev/null
@@ -0,0 +1,8 @@
+Length of  : 0
+Length of x : 1
+Length of 01234567890123456789012345678901234567890123456789012345678901234567890123456789 : 80
+Now is the time[0] = "N"
+Now is the time[1] = "o"
+Now is the time[10] = " "
+Now is the time[last] = "e"
+Num throws 2000
diff --git a/test/082-inline-execute/info.txt b/test/082-inline-execute/info.txt
new file mode 100644 (file)
index 0000000..ddc31fe
--- /dev/null
@@ -0,0 +1,8 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+This test covers the string inline-execute tests, and it done in a
+looping manner to ensure that the tests are translated when a Jit is
+active.
diff --git a/test/082-inline-execute/src/Main.java b/test/082-inline-execute/src/Main.java
new file mode 100644 (file)
index 0000000..b512091
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Test for Jit's handling of string inline-execute.  Should be tested
+ * twice - once using self-cosimulation (if available) and once without.
+ * The non-self-cosimulation test ensures that the answer computed the first
+ * time through (via the interpreter) is the same after looping enough
+ * to trigger translation.
+ */
+
+import junit.framework.Assert;
+
+public class Main {
+    public static void main(String args[]) {
+        int i;
+        stringLengthTest();
+        stringCharAtTest();
+        stringIndexOfTest();
+        for (i = 0; i < 1000; i++)
+            stringCompareToTest();
+    }
+
+    public static void stringLengthTest() {
+        String str0 = "";
+        String str1 = "x";
+        String str80 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789";
+        int len0 = str0.length();
+        int len1 = str1.length();
+        int len80 = str80.length();
+        int i;
+
+        System.out.println("Length of " + str0 + " : " + len0);
+        System.out.println("Length of " + str1 + " : " + len1);
+        System.out.println("Length of " + str80 + " : " + len80);
+
+        for (i = 0; i < 1000; i++) {
+            assert(str0.length() == len0);
+            assert(str1.length() == len1);
+            assert(str80.length() == len80);
+        }
+    }
+
+    public static void stringCharAtTest() {
+        String testStr = "Now is the time";
+        int under = -1;
+        int over = testStr.length();
+        int numThrown = 0;
+        int numNotThrown = 0;
+        int at0 = testStr.charAt(0);
+        int at1 = testStr.charAt(1);
+        int at10 = testStr.charAt(10);
+        int atLast = testStr.charAt(testStr.length()-1);
+        int i;
+
+        System.out.println(testStr + "[0] = \"" + (char)at0 + "\"");
+        System.out.println(testStr + "[1] = \"" + (char)at1 + "\"");
+        System.out.println(testStr + "[10] = \"" + (char)at10 + "\"");
+        System.out.println(testStr + "[last] = \"" + (char)atLast + "\"");
+
+        for (i = 0; i < 1000; i++) {
+            assert(at0 == testStr.charAt(0));
+            assert(at1 == testStr.charAt(1));
+            assert(at10 == testStr.charAt(10));
+            assert(atLast == testStr.charAt(testStr.length()-1));
+        }
+
+        for (i = 0; i < 1000; i++) {
+            try {
+                testStr.charAt(under);
+                numNotThrown++;
+            } catch (StringIndexOutOfBoundsException sioobe) {
+                numThrown++;
+            }
+            try {
+                testStr.charAt(over);
+                numNotThrown++;
+            } catch (StringIndexOutOfBoundsException sioobe) {
+                numThrown++;
+            }
+        }
+        assert(numNotThrown == 0);
+        System.out.println("Num throws " + numThrown);
+    }
+
+
+    public static void stringIndexOfTest() {
+        String str0 = "";
+        String str3 = "abc";
+        String str10 = "abcdefghij";
+        String str40 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabc";
+        int i;
+
+        for (i = 0; i < 1000; i++) {
+            assert(str0.indexOf('a') == -1);
+            assert(str3.indexOf('a') == 0);
+            assert(str3.indexOf('b') == 1);
+            assert(str3.indexOf('c') == 2);
+            assert(str10.indexOf('j') == 9);
+            assert(str40.indexOf('a') == 0);
+            assert(str40.indexOf('b') == 38);
+            assert(str40.indexOf('c') == 39);
+            assert(str0.indexOf('a',20) == -1);
+            assert(str0.indexOf('a',0) == -1);
+            assert(str0.indexOf('a',-1) == -1);
+            assert(str3.indexOf('a',0) == 0);
+            assert(str3.indexOf('a',1) == -1);
+            assert(str3.indexOf('a',1234) == -1);
+            assert(str3.indexOf('b',0) == 1);
+            assert(str3.indexOf('b',1) == 1);
+            assert(str3.indexOf('c',2) == 2);
+            assert(str10.indexOf('j',5) == 9);
+            assert(str10.indexOf('j',9) == 9);
+            assert(str40.indexOf('a',10) == 10);
+            assert(str40.indexOf('b',40) == -1);
+        }
+
+    }
+
+    public static void stringCompareToTest() {
+        String test = "0123456789";
+        String test1 = new String("0123456789");    // different object
+        String test2 = new String("0123456780");    // different value
+        String offset = new String("xxx0123456789yyy");
+        String sub = offset.substring(3, 13);
+        String str32 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+        String str33 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy";
+        String lc = "abcdefg";
+        String uc = "ABCDEFG";
+        Object blah = new Object();
+
+        for (int i = 0; i < 100; i++) {
+            String y = lc.toUpperCase();
+            Assert.assertTrue(y.equals(uc));
+        }
+
+        Assert.assertEquals(str32.compareTo(str33), -1);
+        Assert.assertEquals(str33.compareTo(str32), 1);
+
+        Assert.assertTrue(test.equals(test));
+        Assert.assertTrue(test.equals(test1));
+        Assert.assertFalse(test.equals(test2));
+
+        Assert.assertEquals(test.compareTo(test1), 0);
+        Assert.assertTrue(test1.compareTo(test2) > 0);
+        Assert.assertTrue(test2.compareTo(test1) < 0);
+
+        /* compare string with a nonzero offset, in left/right side */
+        Assert.assertEquals(test.compareTo(sub), 0);
+        Assert.assertEquals(sub.compareTo(test), 0);
+        Assert.assertTrue(test.equals(sub));
+        Assert.assertTrue(sub.equals(test));
+        /* same base, one is a substring */
+        Assert.assertFalse(offset.equals(sub));
+        Assert.assertFalse(sub.equals(offset));
+        /* wrong class */
+        Assert.assertFalse(test.equals(blah));
+
+        /* null ptr - throw */
+        try {
+            test.compareTo(null);
+            Assert.fail("didn't get expected npe");
+        } catch (NullPointerException npe) {
+        }
+        /* null ptr - ok */
+        Assert.assertFalse(test.equals(null));
+
+        test = test.substring(1);
+        Assert.assertTrue(test.equals("123456789"));
+        Assert.assertFalse(test.equals(test1));
+
+        test = test.substring(1);
+        Assert.assertTrue(test.equals("23456789"));
+
+        test = test.substring(1);
+        Assert.assertTrue(test.equals("3456789"));
+
+        test = test.substring(1);
+        Assert.assertTrue(test.equals("456789"));
+
+        test = test.substring(3,5);
+        Assert.assertTrue(test.equals("78"));
+
+        test = "this/is/a/path";
+        String[] strings = test.split("/");
+        Assert.assertEquals(4, strings.length);
+
+        Assert.assertEquals("this is a path", test.replaceAll("/", " "));
+        Assert.assertEquals("this is a path", test.replace("/", " "));
+    }
+
+}
diff --git a/test/082-inline-execute/src/junit/framework/Assert.java b/test/082-inline-execute/src/junit/framework/Assert.java
new file mode 100644 (file)
index 0000000..364e646
--- /dev/null
@@ -0,0 +1,291 @@
+package junit.framework;
+
+/**
+ * A set of assert methods.  Messages are only displayed when an assert fails.
+ */
+
+public class Assert {
+    /**
+     * Protect constructor since it is a static only class
+     */
+    protected Assert() {
+    }
+
+    /**
+     * Asserts that a condition is true. If it isn't it throws
+     * an AssertionFailedError with the given message.
+     */
+    static public void assertTrue(String message, boolean condition) {
+        if (!condition)
+            fail(message);
+    }
+    /**
+     * Asserts that a condition is true. If it isn't it throws
+     * an AssertionFailedError.
+     */
+    static public void assertTrue(boolean condition) {
+        assertTrue(null, condition);
+    }
+    /**
+     * Asserts that a condition is false. If it isn't it throws
+     * an AssertionFailedError with the given message.
+     */
+    static public void assertFalse(String message, boolean condition) {
+        assertTrue(message, !condition);
+    }
+    /**
+     * Asserts that a condition is false. If it isn't it throws
+     * an AssertionFailedError.
+     */
+    static public void assertFalse(boolean condition) {
+        assertFalse(null, condition);
+    }
+    /**
+     * Fails a test with the given message.
+     */
+    static public void fail(String message) {
+        throw new AssertionFailedError(message);
+    }
+    /**
+     * Fails a test with no message.
+     */
+    static public void fail() {
+        fail(null);
+    }
+    /**
+     * Asserts that two objects are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertEquals(String message, Object expected, Object actual) {
+        if (expected == null && actual == null)
+            return;
+        if (expected != null && expected.equals(actual))
+            return;
+        failNotEquals(message, expected, actual);
+    }
+    /**
+     * Asserts that two objects are equal. If they are not
+     * an AssertionFailedError is thrown.
+     */
+    static public void assertEquals(Object expected, Object actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two Strings are equal.
+     */
+    static public void assertEquals(String message, String expected, String actual) {
+        if (expected == null && actual == null)
+            return;
+        if (expected != null && expected.equals(actual))
+            return;
+        throw new ComparisonFailure(message, expected, actual);
+    }
+    /**
+     * Asserts that two Strings are equal.
+     */
+    static public void assertEquals(String expected, String actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two doubles are equal concerning a delta.  If they are not
+     * an AssertionFailedError is thrown with the given message.  If the expected
+     * value is infinity then the delta value is ignored.
+     */
+    static public void assertEquals(String message, double expected, double actual, double delta) {
+        // handle infinity specially since subtracting to infinite values gives NaN and the
+        // the following test fails
+        if (Double.isInfinite(expected)) {
+            if (!(expected == actual))
+                failNotEquals(message, new Double(expected), new Double(actual));
+        } else if (!(Math.abs(expected-actual) <= delta)) // Because comparison with NaN always returns false
+            failNotEquals(message, new Double(expected), new Double(actual));
+    }
+    /**
+     * Asserts that two doubles are equal concerning a delta. If the expected
+     * value is infinity then the delta value is ignored.
+     */
+    static public void assertEquals(double expected, double actual, double delta) {
+        assertEquals(null, expected, actual, delta);
+    }
+    /**
+     * Asserts that two floats are equal concerning a delta. If they are not
+     * an AssertionFailedError is thrown with the given message.  If the expected
+     * value is infinity then the delta value is ignored.
+     */
+    static public void assertEquals(String message, float expected, float actual, float delta) {
+         // handle infinity specially since subtracting to infinite values gives NaN and the
+        // the following test fails
+        if (Float.isInfinite(expected)) {
+            if (!(expected == actual))
+                failNotEquals(message, new Float(expected), new Float(actual));
+        } else if (!(Math.abs(expected-actual) <= delta))
+              failNotEquals(message, new Float(expected), new Float(actual));
+    }
+    /**
+     * Asserts that two floats are equal concerning a delta. If the expected
+     * value is infinity then the delta value is ignored.
+     */
+    static public void assertEquals(float expected, float actual, float delta) {
+        assertEquals(null, expected, actual, delta);
+    }
+    /**
+     * Asserts that two longs are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertEquals(String message, long expected, long actual) {
+        assertEquals(message, new Long(expected), new Long(actual));
+    }
+    /**
+     * Asserts that two longs are equal.
+     */
+    static public void assertEquals(long expected, long actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two booleans are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertEquals(String message, boolean expected, boolean actual) {
+            assertEquals(message, new Boolean(expected), new Boolean(actual));
+      }
+    /**
+     * Asserts that two booleans are equal.
+      */
+    static public void assertEquals(boolean expected, boolean actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two bytes are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+      static public void assertEquals(String message, byte expected, byte actual) {
+        assertEquals(message, new Byte(expected), new Byte(actual));
+    }
+    /**
+        * Asserts that two bytes are equal.
+     */
+    static public void assertEquals(byte expected, byte actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two chars are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+      static public void assertEquals(String message, char expected, char actual) {
+            assertEquals(message, new Character(expected), new Character(actual));
+      }
+    /**
+     * Asserts that two chars are equal.
+     */
+      static public void assertEquals(char expected, char actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two shorts are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertEquals(String message, short expected, short actual) {
+            assertEquals(message, new Short(expected), new Short(actual));
+    }
+      /**
+     * Asserts that two shorts are equal.
+     */
+    static public void assertEquals(short expected, short actual) {
+        assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that two ints are equal. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+      static public void assertEquals(String message, int expected, int actual) {
+        assertEquals(message, new Integer(expected), new Integer(actual));
+      }
+      /**
+        * Asserts that two ints are equal.
+     */
+      static public void assertEquals(int expected, int actual) {
+          assertEquals(null, expected, actual);
+    }
+    /**
+     * Asserts that an object isn't null.
+     */
+    static public void assertNotNull(Object object) {
+        assertNotNull(null, object);
+    }
+    /**
+     * Asserts that an object isn't null. If it is
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertNotNull(String message, Object object) {
+        assertTrue(message, object != null);
+    }
+    /**
+     * Asserts that an object is null.
+     */
+    static public void assertNull(Object object) {
+        assertNull(null, object);
+    }
+    /**
+     * Asserts that an object is null.  If it is not
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertNull(String message, Object object) {
+        assertTrue(message, object == null);
+    }
+    /**
+     * Asserts that two objects refer to the same object. If they are not
+     * an AssertionFailedError is thrown with the given message.
+     */
+    static public void assertSame(String message, Object expected, Object actual) {
+        if (expected == actual)
+            return;
+        failNotSame(message, expected, actual);
+    }
+    /**
+     * Asserts that two objects refer to the same object. If they are not
+     * the same an AssertionFailedError is thrown.
+     */
+    static public void assertSame(Object expected, Object actual) {
+        assertSame(null, expected, actual);
+    }
+     /**
+      * Asserts that two objects refer to the same object. If they are not
+      * an AssertionFailedError is thrown with the given message.
+      */
+    static public void assertNotSame(String message, Object expected, Object actual) {
+        if (expected == actual)
+            failSame(message);
+    }
+    /**
+     * Asserts that two objects refer to the same object. If they are not
+     * the same an AssertionFailedError is thrown.
+     */
+    static public void assertNotSame(Object expected, Object actual) {
+        assertNotSame(null, expected, actual);
+    }
+
+    static private void failSame(String message) {
+        String formatted= "";
+         if (message != null)
+             formatted= message+" ";
+         fail(formatted+"expected not same");
+    }
+
+    static private void failNotSame(String message, Object expected, Object actual) {
+        String formatted= "";
+        if (message != null)
+            formatted= message+" ";
+        fail(formatted+"expected same:<"+expected+"> was not:<"+actual+">");
+    }
+
+    static private void failNotEquals(String message, Object expected, Object actual) {
+        fail(format(message, expected, actual));
+    }
+
+    static String format(String message, Object expected, Object actual) {
+        String formatted= "";
+        if (message != null)
+            formatted= message+" ";
+        return formatted+"expected:<"+expected+"> but was:<"+actual+">";
+    }
+}
diff --git a/test/082-inline-execute/src/junit/framework/AssertionFailedError.java b/test/082-inline-execute/src/junit/framework/AssertionFailedError.java
new file mode 100644 (file)
index 0000000..e9cb3a3
--- /dev/null
@@ -0,0 +1,13 @@
+package junit.framework;
+
+/**
+ * Thrown when an assertion failed.
+ */
+public class AssertionFailedError extends Error {
+
+    public AssertionFailedError () {
+    }
+    public AssertionFailedError (String message) {
+        super (message);
+    }
+}
diff --git a/test/082-inline-execute/src/junit/framework/ComparisonFailure.java b/test/082-inline-execute/src/junit/framework/ComparisonFailure.java
new file mode 100644 (file)
index 0000000..0cb2cee
--- /dev/null
@@ -0,0 +1,68 @@
+package junit.framework;
+
+/**
+ * Thrown when an assert equals for Strings failed.
+ *
+ * Inspired by a patch from Alex Chaffee mailto:alex@purpletech.com
+ */
+public class ComparisonFailure extends AssertionFailedError {
+    private String fExpected;
+    private String fActual;
+
+    /**
+     * Constructs a comparison failure.
+     * @param message the identifying message or null
+     * @param expected the expected string value
+     * @param actual the actual string value
+     */
+    public ComparisonFailure (String message, String expected, String actual) {
+        super (message);
+        fExpected= expected;
+        fActual= actual;
+    }
+
+    /**
+     * Returns "..." in place of common prefix and "..." in
+     * place of common suffix between expected and actual.
+     *
+     * @see java.lang.Throwable#getMessage()
+     */
+    public String getMessage() {
+        if (fExpected == null || fActual == null)
+            return Assert.format(super.getMessage(), fExpected, fActual);
+
+        int end= Math.min(fExpected.length(), fActual.length());
+
+        int i= 0;
+        for(; i < end; i++) {
+            if (fExpected.charAt(i) != fActual.charAt(i))
+                break;
+        }
+        int j= fExpected.length()-1;
+        int k= fActual.length()-1;
+        for (; k >= i && j >= i; k--,j--) {
+            if (fExpected.charAt(j) != fActual.charAt(k))
+                break;
+        }
+        String actual, expected;
+
+        // equal strings
+        if (j < i && k < i) {
+            expected= fExpected;
+            actual= fActual;
+        } else {
+            expected= fExpected.substring(i, j+1);
+            actual= fActual.substring(i, k+1);
+            if (i <= end && i > 0) {
+                expected= "..."+expected;
+                actual= "..."+actual;
+            }
+
+            if (j < fExpected.length()-1)
+                expected= expected+"...";
+            if (k < fActual.length()-1)
+                actual= actual+"...";
+        }
+        return Assert.format(super.getMessage(), expected, actual);
+    }
+}
diff --git a/test/083-jit-regressions/expected.txt b/test/083-jit-regressions/expected.txt
new file mode 100644 (file)
index 0000000..1f30d21
--- /dev/null
@@ -0,0 +1,3 @@
+b2296099 passes
+b2302318 passes
+b2487514 passes
diff --git a/test/083-jit-regressions/info.txt b/test/083-jit-regressions/info.txt
new file mode 100644 (file)
index 0000000..b791aba
--- /dev/null
@@ -0,0 +1,10 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+This test covers JIT regressions
+
+2296099 JIT shift bug
+2302318 Crash during spin-on-suspend testing
+2487514 Missed exception in PriorityBlockingQueueTest.testToArray1_BadArg
diff --git a/test/083-jit-regressions/src/Main.java b/test/083-jit-regressions/src/Main.java
new file mode 100644 (file)
index 0000000..1f1dee3
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+import java.util.concurrent.*;
+
+/**
+ * Test for Jit regressions.
+ */
+public class Main {
+    public static void main(String args[]) throws Exception {
+        b2296099Test();
+        b2302318Test();
+        b2487514Test();
+    }
+
+    static void b2296099Test() throws Exception {
+       int x = -1190771042;
+       int dist = 360530809;
+       int xl = -1190771042;
+       int distl = 360530809;
+
+       for (int i = 0; i < 100000; i++) {
+           int b = rotateLeft(x, dist);
+           if (b != 1030884493)
+               throw new RuntimeException("Unexpected value: " + b
+                       + " after " + i + " iterations");
+       }
+       for (int i = 0; i < 100000; i++) {
+           long bl = rotateLeft(xl, distl);
+           if (bl != 1030884493)
+               throw new RuntimeException("Unexpected value: " + bl
+                       + " after " + i + " iterations");
+       }
+       System.out.println("b2296099 passes");
+   }
+
+    static int rotateLeft(int i, int distance) {
+        return ((i << distance) | (i >>> (-distance)));
+    }
+
+    static void b2302318Test() {
+        System.gc();
+
+        SpinThread slow = new SpinThread(Thread.MIN_PRIORITY);
+        SpinThread fast1 = new SpinThread(Thread.NORM_PRIORITY);
+        SpinThread fast2 = new SpinThread(Thread.MAX_PRIORITY);
+
+        slow.setDaemon(true);
+        fast1.setDaemon(true);
+        fast2.setDaemon(true);
+
+        fast2.start();
+        slow.start();
+        fast1.start();
+        try {
+            Thread.sleep(3000);
+        } catch (InterruptedException ie) {/*ignore */}
+        System.gc();
+
+        System.out.println("b2302318 passes");
+    }
+
+    static void b2487514Test() {
+        PriorityBlockingQueue q = new PriorityBlockingQueue(10);
+        int catchCount = 0;
+
+        q.offer(new Integer(0));
+        /*
+         * Warm up the code cache to have toArray() compiled. The key here is
+         * to pass a compatible type so that there are no exceptions when
+         * executing the method body (ie the APUT_OBJECT bytecode).
+         */
+        for (int i = 0; i < 1000; i++) {
+            Integer[] ints = (Integer[]) q.toArray(new Integer[5]);
+        }
+
+        /* Now pass an incompatible type which is guaranteed to throw */
+        for (int i = 0; i < 1000; i++) {
+            try {
+                Object[] obj = q.toArray(new String[5]);
+            }
+            catch (ArrayStoreException  success) {
+                catchCount++;
+            }
+        }
+
+        if (catchCount == 1000) {
+            System.out.println("b2487514 passes");
+        }
+        else {
+            System.out.println("b2487514 fails: catchCount is " + catchCount +
+                               " (expecting 1000)");
+        }
+    }
+}
+
+class SpinThread extends Thread {
+    int mPriority;
+
+    SpinThread(int prio) {
+        super("Spin prio=" + prio);
+        mPriority = prio;
+    }
+
+    public void run() {
+        setPriority(mPriority);
+        while (true) {}
+    }
+}
diff --git a/test/084-class-init/expected.txt b/test/084-class-init/expected.txt
new file mode 100644 (file)
index 0000000..6e74fbb
--- /dev/null
@@ -0,0 +1,8 @@
+Got expected EIIE for FIELD0
+Got expected NCDFE for FIELD0
+Got expected NCDFE for FIELD1
+SlowInit static block pre-sleep
+SlowInit static block post-sleep
+MethodThread message
+Fields (child thread): 111222333444
+Fields (main thread): 111222333444
diff --git a/test/084-class-init/info.txt b/test/084-class-init/info.txt
new file mode 100644 (file)
index 0000000..00fa31b
--- /dev/null
@@ -0,0 +1 @@
+Test class initialization edge cases and race conditions.
diff --git a/test/084-class-init/src/IntHolder.java b/test/084-class-init/src/IntHolder.java
new file mode 100644 (file)
index 0000000..4012d6e
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+
+/**
+ * Holds an int.
+ */
+public class IntHolder {
+    private int mValue = 0;
+
+    /**
+     * Constructs an IntHolder with the specified value.  Throws an
+     * exception if the initial value is less than zero.
+     */
+    public IntHolder(int initialVal) {
+        if (initialVal < 0)
+            throw new RuntimeException("negative number");
+
+        mValue = initialVal;
+    }
+
+    public int getValue() {
+        return mValue;
+    }
+    public void setValue(int val) {
+        mValue = val;
+    }
+}
diff --git a/test/084-class-init/src/Main.java b/test/084-class-init/src/Main.java
new file mode 100644 (file)
index 0000000..f777113
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+public class Main {
+    public static void main(String[] args) {
+        checkExceptions();
+        checkTiming();
+    }
+
+    public static void sleep(int msec) {
+        try {
+            Thread.sleep(msec);
+        } catch (InterruptedException ie) {
+            System.err.println("sleep interrupted");
+        }
+    }
+
+    static void checkExceptions() {
+        try {
+            System.out.println(PartialInit.FIELD0);
+            System.err.println("Construction of PartialInit succeeded unexpectedly");
+        } catch (ExceptionInInitializerError eiie) {
+            System.out.println("Got expected EIIE for FIELD0");
+        }
+
+        try {
+            System.out.println(PartialInit.FIELD0);
+            System.err.println("Load of FIELD0 succeeded unexpectedly");
+        } catch (NoClassDefFoundError ncdfe) {
+            System.out.println("Got expected NCDFE for FIELD0");
+        }
+        try {
+            System.out.println(PartialInit.FIELD1);
+            System.err.println("Load of FIELD1 succeeded unexpectedly");
+        } catch (NoClassDefFoundError ncdfe) {
+            System.out.println("Got expected NCDFE for FIELD1");
+        }
+    }
+
+    static void checkTiming() {
+        FieldThread fieldThread = new FieldThread();
+        MethodThread methodThread = new MethodThread();
+
+        fieldThread.start();
+        methodThread.start();
+
+        /* start class init */
+        IntHolder zero = SlowInit.FIELD0;
+
+        /* wait for children to complete */
+        try {
+            fieldThread.join();
+            methodThread.join();
+        } catch (InterruptedException ie) {
+            System.err.println(ie);
+        }
+
+        /* print all values */
+        System.out.println("Fields (main thread): " +
+            SlowInit.FIELD0.getValue() + SlowInit.FIELD1.getValue() +
+            SlowInit.FIELD2.getValue() + SlowInit.FIELD3.getValue());
+    }
+
+    static class FieldThread extends Thread {
+        public void run() {
+            /* allow class init to start */
+            Main.sleep(200);
+
+            /* collect fields; should delay until class init completes */
+            int field0, field1, field2, field3;
+            field0 = SlowInit.FIELD0.getValue();
+            field1 = SlowInit.FIELD1.getValue();
+            field2 = SlowInit.FIELD2.getValue();
+            field3 = SlowInit.FIELD3.getValue();
+
+            /* let MethodThread print first */
+            Main.sleep(400);
+            System.out.println("Fields (child thread): " +
+                field0 + field1 + field2 + field3);
+        }
+    }
+
+    static class MethodThread extends Thread {
+        public void run() {
+            /* allow class init to start */
+            Main.sleep(200);
+
+            /* use a method that shouldn't be accessible yet */
+            SlowInit.printMsg("MethodThread message");
+        }
+    }
+}
diff --git a/test/084-class-init/src/PartialInit.java b/test/084-class-init/src/PartialInit.java
new file mode 100644 (file)
index 0000000..d4c71ff
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+
+/**
+ * Partially-initialized class.
+ */
+public class PartialInit {
+    public static final IntHolder FIELD0 = new IntHolder(1);    // succeeds
+    public static final IntHolder FIELD1 = new IntHolder(-2);   // throws
+}
diff --git a/test/084-class-init/src/SlowInit.java b/test/084-class-init/src/SlowInit.java
new file mode 100644 (file)
index 0000000..8ac72be
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+/**
+ * Class that initializes with a pause.
+ */
+public class SlowInit {
+
+    public static final IntHolder FIELD0 = new IntHolder(0);
+    public static final IntHolder FIELD1 = new IntHolder(0);
+    public static final IntHolder FIELD2 = new IntHolder(0);
+    public static final IntHolder FIELD3 = new IntHolder(0);
+
+    public static void printMsg(String msg) {
+        System.out.println(msg);
+    }
+
+    static {
+        FIELD0.setValue(111);
+        FIELD1.setValue(222);
+        printMsg("SlowInit static block pre-sleep");
+        Main.sleep(600);
+        printMsg("SlowInit static block post-sleep");
+        FIELD2.setValue(333);
+        FIELD3.setValue(444);
+    };
+}
diff --git a/test/085-old-style-inner-class/build b/test/085-old-style-inner-class/build
new file mode 100644 (file)
index 0000000..dc6f3bb
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash
+#
+# Copyright (C) 2010 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.
+
+# Stop if something fails.
+set -e
+
+# We compile for a 1.4 target to suppress the use of EnclosingMethod
+# attributes.
+mkdir classes
+${JAVAC} -source 1.4 -target 1.4 -d classes `find src -name '*.java'`
+
+# Suppress stderr to keep the inner class warnings out of the expected output.
+dx --debug --dex --dump-to=classes.lst --output=classes.dex \
+    --dump-width=1000 classes 2>/dev/null
+
+zip test.jar classes.dex
diff --git a/test/085-old-style-inner-class/expected.txt b/test/085-old-style-inner-class/expected.txt
new file mode 100644 (file)
index 0000000..63a0076
--- /dev/null
@@ -0,0 +1,8 @@
+Class: Main$1
+  getDeclaringClass(): (null)
+  getEnclosingClass(): (null)
+  getEnclosingMethod(): (null)
+Class: Main$2
+  getDeclaringClass(): (null)
+  getEnclosingClass(): (null)
+  getEnclosingMethod(): (null)
diff --git a/test/085-old-style-inner-class/info.txt b/test/085-old-style-inner-class/info.txt
new file mode 100644 (file)
index 0000000..9e5c4f9
--- /dev/null
@@ -0,0 +1,2 @@
+Test that the conversion of an old-style (pre-1.5) inner class results
+in a loss of inner class reflection information.
diff --git a/test/085-old-style-inner-class/src/Main.java b/test/085-old-style-inner-class/src/Main.java
new file mode 100644 (file)
index 0000000..c9a5b72
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+import java.lang.reflect.Method;
+
+/**
+ * Test reflection on old-style inner classes.
+ */
+public class Main {
+    private static Runnable theRunnable = new Runnable() {
+            public void run() { }
+        };
+
+    private static Runnable create() {
+        return new Runnable() {
+                public void run() { }
+            };
+    }
+
+    private static String nameOf(Class clazz) {
+        return (clazz == null) ? "(null)" : clazz.getName();
+    }
+
+    private static String nameOf(Method meth) {
+        return (meth == null) ? "(null)" : meth.toString();
+    }
+
+    private static void infoFor(Class clazz) {
+        System.out.println("Class: " + nameOf(clazz) + "\n" +
+                "  getDeclaringClass(): " +
+                nameOf(clazz.getDeclaringClass()) + "\n" +
+                "  getEnclosingClass(): " +
+                nameOf(clazz.getEnclosingClass()) + "\n" +
+                "  getEnclosingMethod(): " +
+                nameOf(clazz.getEnclosingMethod()));
+    }
+
+    public static void main(String args[]) {
+        infoFor(theRunnable.getClass());
+        infoFor(create().getClass());
+    }
+}
diff --git a/test/086-null-super/expected.txt b/test/086-null-super/expected.txt
new file mode 100644 (file)
index 0000000..20c6796
--- /dev/null
@@ -0,0 +1 @@
+Got expected ITE/NPE
diff --git a/test/086-null-super/info.txt b/test/086-null-super/info.txt
new file mode 100644 (file)
index 0000000..f983bd0
--- /dev/null
@@ -0,0 +1,7 @@
+ClassLoader.loadClass() is expected to throw an exception, usually
+ClassNotFound, if it can't find the given Class, and not return null.
+
+This is a regression test for a defect in Dalvik, which was assuming
+that if there was no exception, the value returned would be non-null.
+
+This test is not expected to work for the reference implementation.
diff --git a/test/086-null-super/src/Main.java b/test/086-null-super/src/Main.java
new file mode 100644 (file)
index 0000000..6decb20
--- /dev/null
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * Class loader test.
+ */
+public class Main {
+    /**
+     * Thrown when an unexpected Exception is caught internally.
+     */
+    static class TestFailed extends Exception {
+        public TestFailed(Throwable cause) {
+            super(cause);
+        }
+    }
+
+    /**
+     * A class loader which loads classes from the dex file
+     * "test.jar". However, it will return null when asked to load the
+     * class InaccessibleSuper.
+     *
+     * When testing code calls BrokenDexLoader's findBrokenClass(),
+     * a BrokenDexLoader will be the defining loader for the class
+     * Inaccessible.  The VM will call the defining loader for
+     * "InaccessibleSuper", which will return null, which the VM
+     * should be able to deal with gracefully.
+     *
+     * Note that this depends heavily on the Dalvik test harness.
+     */
+    static class BrokenDexLoader extends ClassLoader {
+
+        /** We return null when asked to load InaccessibleSuper. */
+        private static class InaccessibleSuper {}
+        private static class Inaccessible extends InaccessibleSuper {}
+
+        private static final String SUPERCLASS_NAME =
+                "Main$BrokenDexLoader$InaccessibleSuper";
+        private static final String CLASS_NAME =
+                "Main$BrokenDexLoader$Inaccessible";
+
+        private static final String DEX_FILE = "test.jar";
+
+        public BrokenDexLoader(ClassLoader parent) {
+            super(parent);
+        }
+
+        /**
+         * Finds the class with the specified binary name, from DEX_FILE.
+         *
+         * If we don't find a match, we throw an exception.
+         */
+        private Class<?> findDexClass(String name)
+                throws TestFailed, InvocationTargetException
+        {
+
+            try {
+                /*
+                 * Find the DexFile class, and construct a DexFile object
+                 * through reflection, then call loadCLass on it.
+                 */
+                Class mDexClass = ClassLoader.getSystemClassLoader().
+                        loadClass("dalvik/system/DexFile");
+                Constructor ctor = mDexClass.
+                        getConstructor(new Class[] {String.class});
+                Object mDexFile = ctor.newInstance(DEX_FILE);
+                Method meth = mDexClass.
+                        getMethod("loadClass",
+                            new Class[] { String.class, ClassLoader.class });
+                /*
+                 * Invoking loadClass on CLASS_NAME is expected to
+                 * throw an InvocationTargetException. Anything else
+                 * is an error we can't recover from.
+                 */
+                meth.invoke(mDexFile, name, this);
+            } catch (NoSuchMethodException nsme) {
+                throw new TestFailed(nsme);
+            } catch (InstantiationException ie) {
+                throw new TestFailed(ie);
+            } catch (IllegalAccessException iae) {
+                throw new TestFailed(iae);
+            } catch (ClassNotFoundException cnfe) {
+                throw new TestFailed(cnfe);
+            }
+
+            return null;
+        }
+
+        /**
+         * Load a class.
+         *
+         * Return null if the class's name is SUPERCLASS_NAME;
+         * otherwise invoke the super's loadClass method.
+         */
+        public Class<?> loadClass(String name, boolean resolve)
+                throws ClassNotFoundException
+        {
+            if (SUPERCLASS_NAME.equals(name)) {
+                return null;
+            }
+
+            return super.loadClass(name, resolve);
+        }
+
+        /**
+         * Attempt to find the class with the superclass we refuse to
+         * load.  This is expected to throw an
+         * InvocationTargetException, with a NullPointerException as
+         * its cause.
+         */
+        public void findBrokenClass()
+                throws TestFailed, InvocationTargetException
+        {
+            findDexClass(CLASS_NAME);
+        }
+    }
+
+    /**
+     * Main entry point.
+     */
+    public static void main(String[] args)
+            throws TestFailed, ClassNotFoundException {
+        /*
+         * Run test.
+         */
+        testFailLoadAndGc();
+    }
+
+    /**
+     * See if we can GC after a failed load.
+     */
+    static void testFailLoadAndGc() throws TestFailed {
+        try {
+            BrokenDexLoader loader;
+
+            loader = new BrokenDexLoader(ClassLoader.getSystemClassLoader());
+            loader.findBrokenClass();
+            System.err.println("ERROR: Inaccessible was accessible");
+        } catch (InvocationTargetException ite) {
+            Throwable cause = ite.getCause();
+            if (cause instanceof NullPointerException) {
+                System.err.println("Got expected ITE/NPE");
+            } else {
+                System.err.println("Got unexpected ITE");
+                ite.printStackTrace();
+            }
+        }
+    }
+}
diff --git a/test/087-gc-after-link/expected.txt b/test/087-gc-after-link/expected.txt
new file mode 100644 (file)
index 0000000..3b2d33a
--- /dev/null
@@ -0,0 +1,2 @@
+Got expected ITE/NPE
+GC complete.
diff --git a/test/087-gc-after-link/info.txt b/test/087-gc-after-link/info.txt
new file mode 100644 (file)
index 0000000..9483838
--- /dev/null
@@ -0,0 +1,8 @@
+This test causes a linkage error, which calls dvmFreeClassInnards on
+the unlinked Class.
+
+This is a regression test for a defect in Dalvik, which was assuming
+that dvmFreeClassInnards could be called twice on the same class.
+
+This test is a modified version of test 086.
+This test is not expected to work for the reference implementation.
diff --git a/test/087-gc-after-link/src/Main.java b/test/087-gc-after-link/src/Main.java
new file mode 100644 (file)
index 0000000..dc68f9f
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * Class loader test.
+ */
+public class Main {
+    /**
+     * Thrown when an unexpected Exception is caught internally.
+     */
+    static class TestFailed extends Exception {
+        public TestFailed(Throwable cause) {
+            super(cause);
+        }
+    }
+
+    /**
+     * A class loader which loads classes from the dex file
+     * "test.jar". However, it will return null when asked to load the
+     * class InaccessibleSuper.
+     *
+     * When testing code calls BrokenDexLoader's findBrokenClass(),
+     * a BrokenDexLoader will be the defining loader for the class
+     * Inaccessible.  The VM will call the defining loader for
+     * "InaccessibleSuper", which will return null, which the VM
+     * should be able to deal with gracefully.
+     *
+     * Note that this depends heavily on the Dalvik test harness.
+     */
+    static class BrokenDexLoader extends ClassLoader {
+
+        /** We return null when asked to load InaccessibleSuper. */
+        private static class InaccessibleSuper {}
+        private static class Inaccessible extends InaccessibleSuper {}
+
+        private static final String SUPERCLASS_NAME =
+                "Main$BrokenDexLoader$InaccessibleSuper";
+        private static final String CLASS_NAME =
+                "Main$BrokenDexLoader$Inaccessible";
+
+        private static final String DEX_FILE = "test.jar";
+
+        public BrokenDexLoader(ClassLoader parent) {
+            super(parent);
+        }
+
+        /**
+         * Finds the class with the specified binary name, from DEX_FILE.
+         *
+         * If we don't find a match, we throw an exception.
+         */
+        private Class<?> findDexClass(String name)
+                throws TestFailed, InvocationTargetException
+        {
+            Object dexFile = null;
+            Class dexClass = null;
+
+            try {
+                try {
+                    /*
+                     * Find the DexFile class, and construct a DexFile object
+                     * through reflection, then call loadClass on it.
+                     */
+                    dexClass = ClassLoader.getSystemClassLoader().
+                            loadClass("dalvik/system/DexFile");
+                    Constructor ctor = dexClass.
+                            getConstructor(new Class[] {String.class});
+                    dexFile = ctor.newInstance(DEX_FILE);
+                    Method meth = dexClass.getMethod("loadClass",
+                            new Class[] { String.class, ClassLoader.class });
+                    /*
+                     * Invoking loadClass on CLASS_NAME is expected to
+                     * throw an InvocationTargetException. Anything else
+                     * is an error we can't recover from.
+                     */
+                    meth.invoke(dexFile, name, this);
+                } finally {
+                    if (dexFile != null) {
+                        /* close the DexFile to make CloseGuard happy */
+                        Method meth = dexClass.getMethod("close", (Class[]) null);
+                        meth.invoke(dexFile);
+                    }
+                }
+            } catch (NoSuchMethodException nsme) {
+                throw new TestFailed(nsme);
+            } catch (InstantiationException ie) {
+                throw new TestFailed(ie);
+            } catch (IllegalAccessException iae) {
+                throw new TestFailed(iae);
+            } catch (ClassNotFoundException cnfe) {
+                throw new TestFailed(cnfe);
+            }
+
+            return null;
+        }
+
+        /**
+         * Load a class.
+         *
+         * Return null if the class's name is SUPERCLASS_NAME;
+         * otherwise invoke the super's loadClass method.
+         */
+        public Class<?> loadClass(String name, boolean resolve)
+                throws ClassNotFoundException
+        {
+            if (SUPERCLASS_NAME.equals(name)) {
+                return null;
+            }
+
+            return super.loadClass(name, resolve);
+        }
+
+        /**
+         * Attempt to find the class with the superclass we refuse to
+         * load.  This is expected to throw an
+         * InvocationTargetException, with a NullPointerException as
+         * its cause.
+         */
+        public void findBrokenClass()
+                throws TestFailed, InvocationTargetException
+        {
+            findDexClass(CLASS_NAME);
+        }
+    }
+
+    /**
+     * Main entry point.
+     */
+    public static void main(String[] args)
+            throws TestFailed, ClassNotFoundException {
+        /*
+         * Run test.
+         */
+        testFailLoadAndGc();
+    }
+
+    /**
+     * See if we can GC after a failed load.
+     */
+    static void testFailLoadAndGc() throws TestFailed {
+        try {
+            BrokenDexLoader loader;
+
+            loader = new BrokenDexLoader(ClassLoader.getSystemClassLoader());
+            loader.findBrokenClass();
+            System.err.println("ERROR: Inaccessible was accessible");
+        } catch (InvocationTargetException ite) {
+            Throwable cause = ite.getCause();
+            if (cause instanceof NullPointerException) {
+                System.err.println("Got expected ITE/NPE");
+            } else {
+                System.err.println("Got unexpected ITE");
+                ite.printStackTrace();
+            }
+        }
+        System.gc();
+        System.out.println("GC complete.");
+    }
+}
diff --git a/test/088-monitor-verification/expected.txt b/test/088-monitor-verification/expected.txt
new file mode 100644 (file)
index 0000000..07f5b0b
--- /dev/null
@@ -0,0 +1,7 @@
+recursiveSync ok
+nestedMayThrow ok
+constantLock ok
+excessiveNesting ok
+notNested ok
+twoPath ok
+triplet ok
diff --git a/test/088-monitor-verification/info.txt b/test/088-monitor-verification/info.txt
new file mode 100644 (file)
index 0000000..c00cb1c
--- /dev/null
@@ -0,0 +1,2 @@
+Try different arrangements of "synchronized" to exercise the structured
+lock checks in the bytecode verifier.
diff --git a/test/088-monitor-verification/src/Main.java b/test/088-monitor-verification/src/Main.java
new file mode 100644 (file)
index 0000000..aa90b92
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+
+/*
+ * Entry point and tests that are expected to succeed.
+ */
+public class Main {
+    /**
+     * Drives tests.
+     */
+    public static void main(String[] args) {
+        Main m = new Main();
+
+        m.recursiveSync(0);
+
+        m.nestedMayThrow(false);
+        try {
+            m.nestedMayThrow(true);
+            System.err.println("nestedThrow(true) did not throw");
+        } catch (MyException me) {}
+        System.out.println("nestedMayThrow ok");
+
+        m.constantLock();
+        System.out.println("constantLock ok");
+
+        m.notExcessiveNesting();
+        if (false) {    // TODO: remove when verification is turned on
+        try {
+            TooDeep.excessiveNesting();
+            System.err.println("excessiveNesting did not throw");
+        } catch (VerifyError ve) {}
+        }
+        System.out.println("excessiveNesting ok");
+
+        m.notNested();
+        System.out.println("notNested ok");
+
+        Object obj1 = new Object();
+        Object obj2 = new Object();
+
+        m.twoPath(obj1, obj2, 0);
+        System.out.println("twoPath ok");
+
+        m.triplet(obj1, obj2, 0);
+        System.out.println("triplet ok");
+    }
+
+    /**
+     * Recursive synchronized method.
+     */
+    synchronized void recursiveSync(int iter) {
+        if (iter < 40) {
+            recursiveSync(iter+1);
+        } else {
+            System.out.println("recursiveSync ok");
+        }
+    }
+
+    /**
+     * Tests simple nesting, with and without a throw.
+     */
+    void nestedMayThrow(boolean doThrow) {
+        synchronized (this) {
+            synchronized (Main.class) {
+                synchronized (new Object()) {
+                    synchronized(Class.class) {
+                        if (doThrow) {
+                            throw new MyException();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Exercises bug 3215458.
+     */
+    void constantLock() {
+        Class thing = Thread.class;
+        synchronized (Thread.class) {}
+    }
+
+    /**
+     * Confirms that we can have 32 nested monitors on one method.
+     */
+    void notExcessiveNesting() {
+        synchronized (this) {   // 1
+        synchronized (this) {   // 2
+        synchronized (this) {   // 3
+        synchronized (this) {   // 4
+        synchronized (this) {   // 5
+        synchronized (this) {   // 6
+        synchronized (this) {   // 7
+        synchronized (this) {   // 8
+        synchronized (this) {   // 9
+        synchronized (this) {   // 10
+        synchronized (this) {   // 11
+        synchronized (this) {   // 12
+        synchronized (this) {   // 13
+        synchronized (this) {   // 14
+        synchronized (this) {   // 15
+        synchronized (this) {   // 16
+        synchronized (this) {   // 17
+        synchronized (this) {   // 18
+        synchronized (this) {   // 19
+        synchronized (this) {   // 20
+        synchronized (this) {   // 21
+        synchronized (this) {   // 22
+        synchronized (this) {   // 23
+        synchronized (this) {   // 24
+        synchronized (this) {   // 25
+        synchronized (this) {   // 26
+        synchronized (this) {   // 27
+        synchronized (this) {   // 28
+        synchronized (this) {   // 29
+        synchronized (this) {   // 30
+        synchronized (this) {   // 31
+        synchronized (this) {   // 32
+        }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
+    }
+
+    /**
+     * Confirms that we can have more than 32 non-nested monitors in one
+     * method.
+     */
+    void notNested() {
+        synchronized (this) {}  // 1
+        synchronized (this) {}  // 2
+        synchronized (this) {}  // 3
+        synchronized (this) {}  // 4
+        synchronized (this) {}  // 5
+        synchronized (this) {}  // 6
+        synchronized (this) {}  // 7
+        synchronized (this) {}  // 8
+        synchronized (this) {}  // 9
+        synchronized (this) {}  // 10
+        synchronized (this) {}  // 11
+        synchronized (this) {}  // 12
+        synchronized (this) {}  // 13
+        synchronized (this) {}  // 14
+        synchronized (this) {}  // 15
+        synchronized (this) {}  // 16
+        synchronized (this) {}  // 17
+        synchronized (this) {}  // 18
+        synchronized (this) {}  // 19
+        synchronized (this) {}  // 20
+        synchronized (this) {}  // 21
+        synchronized (this) {}  // 22
+        synchronized (this) {}  // 23
+        synchronized (this) {}  // 24
+        synchronized (this) {}  // 25
+        synchronized (this) {}  // 26
+        synchronized (this) {}  // 27
+        synchronized (this) {}  // 28
+        synchronized (this) {}  // 29
+        synchronized (this) {}  // 30
+        synchronized (this) {}  // 31
+        synchronized (this) {}  // 32
+        synchronized (this) {}  // 33
+        synchronized (this) {}  // 34
+    }
+
+    /* does nothing but ensure that the compiler doesn't discard an object */
+    private void doNothing(Object obj) {}
+
+    /**
+     * Conditionally uses one of the synchronized objects.
+     */
+    public void twoPath(Object obj1, Object obj2, int x) {
+        Object localObj;
+
+        synchronized (obj1) {
+            synchronized(obj2) {
+                if (x == 0) {
+                    localObj = obj2;
+                } else {
+                    localObj = obj1;
+                }
+            }
+        }
+
+        doNothing(localObj);
+    }
+
+    /**
+     * Lock the monitor two or three times, and make use of the locked or
+     * unlocked object.
+     */
+    public void triplet(Object obj1, Object obj2, int x) {
+        Object localObj;
+
+        synchronized (obj1) {
+            synchronized(obj1) {
+                if (x == 0) {
+                    synchronized(obj1) {
+                        localObj = obj2;
+                    }
+                } else {
+                    localObj = obj1;
+                }
+            }
+        }
+
+        doNothing(localObj);
+    }
+}
diff --git a/test/088-monitor-verification/src/MyException.java b/test/088-monitor-verification/src/MyException.java
new file mode 100644 (file)
index 0000000..cf65d6d
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+public class MyException extends RuntimeException {
+    public MyException() {
+        super();
+    }
+    public MyException(String msg) {
+        super(msg);
+    }
+}
diff --git a/test/088-monitor-verification/src/TooDeep.java b/test/088-monitor-verification/src/TooDeep.java
new file mode 100644 (file)
index 0000000..76192e5
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+
+/**
+ * The class has a method with too many levels of nested "synchronized"
+ * blocks.  The verifier will reject it.
+ *
+ * (It would be perfectly okay if the verifier *didn't* reject this.
+ * The goal here is just to exercise the failure path.  It also serves
+ * as a check to see if the monitor checks are enabled.)
+ */
+public class TooDeep {
+
+    public static void excessiveNesting() {
+        synchronized (TooDeep.class) {   // 1
+        synchronized (TooDeep.class) {   // 2
+        synchronized (TooDeep.class) {   // 3
+        synchronized (TooDeep.class) {   // 4
+        synchronized (TooDeep.class) {   // 5
+        synchronized (TooDeep.class) {   // 6
+        synchronized (TooDeep.class) {   // 7
+        synchronized (TooDeep.class) {   // 8
+        synchronized (TooDeep.class) {   // 9
+        synchronized (TooDeep.class) {   // 10
+        synchronized (TooDeep.class) {   // 11
+        synchronized (TooDeep.class) {   // 12
+        synchronized (TooDeep.class) {   // 13
+        synchronized (TooDeep.class) {   // 14
+        synchronized (TooDeep.class) {   // 15
+        synchronized (TooDeep.class) {   // 16
+        synchronized (TooDeep.class) {   // 17
+        synchronized (TooDeep.class) {   // 18
+        synchronized (TooDeep.class) {   // 19
+        synchronized (TooDeep.class) {   // 20
+        synchronized (TooDeep.class) {   // 21
+        synchronized (TooDeep.class) {   // 22
+        synchronized (TooDeep.class) {   // 23
+        synchronized (TooDeep.class) {   // 24
+        synchronized (TooDeep.class) {   // 25
+        synchronized (TooDeep.class) {   // 26
+        synchronized (TooDeep.class) {   // 27
+        synchronized (TooDeep.class) {   // 28
+        synchronized (TooDeep.class) {   // 29
+        synchronized (TooDeep.class) {   // 30
+        synchronized (TooDeep.class) {   // 31
+        synchronized (TooDeep.class) {   // 32
+        synchronized (TooDeep.class) {   // 33
+        }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
+    }
+}
diff --git a/test/090-loop-formation/expected.txt b/test/090-loop-formation/expected.txt
new file mode 100644 (file)
index 0000000..b7e0bb3
--- /dev/null
@@ -0,0 +1,5 @@
+counter1 is 0
+counter2 is 32767
+counter3 is 32767
+counter4 is 0
+counter5 is 65534
diff --git a/test/090-loop-formation/info.txt b/test/090-loop-formation/info.txt
new file mode 100644 (file)
index 0000000..98d1d4b
--- /dev/null
@@ -0,0 +1,3 @@
+Test loop formation heuristics and code generation. Basically the problem to
+catch here is to make sure that some never-exercised code blocks are included
+in the loop region, and the JIT compiler won't choke on unresolved fields.
diff --git a/test/090-loop-formation/src/Main.java b/test/090-loop-formation/src/Main.java
new file mode 100644 (file)
index 0000000..7c16667
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+/*
+ * Create two versions of loops where the unresolved field is on either the
+ * taken or the non-taken path to make sure that the loop detection code bails
+ * on unresolved fields.
+ */
+public class Main {
+    static int counter1;
+    static int counter2;
+    static int counter3;
+    static int counter4;
+    static int counter5;
+
+    public static void main(String[] args) {
+        /* counter1 is not resolved */
+        for (int i = 0; i < 32767; i++) {
+            if (i < 0) {
+                counter1++;
+            } else {
+                counter2++;
+            }
+            counter5++;
+        }
+
+        /* counter4 is not resolved */
+        for (int i = 0; i < 32767; i++) {
+            if (i >= 0) {
+                counter3++;
+            } else {
+                counter4++;
+            }
+            counter5++;
+        }
+
+        System.out.println("counter1 is " + counter1);
+        System.out.println("counter2 is " + counter2);
+        System.out.println("counter3 is " + counter3);
+        System.out.println("counter4 is " + counter4);
+        System.out.println("counter5 is " + counter5);
+    }
+}
diff --git a/test/MemUsage/MemUsage.java.orig b/test/MemUsage/MemUsage.java.orig
new file mode 100644 (file)
index 0000000..710031b
--- /dev/null
@@ -0,0 +1,15 @@
+
+public class MemUsage {
+  public static final int ROUNDS = 8;
+  public static final int SIZE = 2000;
+
+  public static void main(String [] args) {
+    String s;
+    for (int j = 0; j < ROUNDS; j++) {
+      s = "";
+      for (int i = 0; i < SIZE; i++) {
+        s += "x";
+      }
+    }
+  }
+}
diff --git a/test/README.txt b/test/README.txt
new file mode 100644 (file)
index 0000000..eb1ce36
--- /dev/null
@@ -0,0 +1,13 @@
+VM test harness.
+
+Use "./run-all-tests" to run all tests, or "./run-test <number>" to run a
+single test.  Run "./run-test" with no arguments to see command flags;
+in particular, the tests can be run on the desktop, on a USB-attached
+device, or using the desktop "reference implementation".
+
+
+For most tests, the sources are in the "src" subdirectory.  Sources found
+in the "src2" directory are compiled separately but to the same output
+directory; this can be used to exercise "API mismatch" situations by
+replacing class files created in the first pass.  The "src-ex" directory
+is built separately, and is intended for exercising class loaders.
diff --git a/test/etc/default-build b/test/etc/default-build
new file mode 100755 (executable)
index 0000000..b8df442
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# 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.
+
+# Stop if something fails.
+set -e
+
+mkdir classes
+${JAVAC} -d classes `find src -name '*.java'`
+
+if [ -r src2 ]; then
+    ${JAVAC} -d classes `find src2 -name '*.java'`
+fi
+
+dx -JXmx256m --debug --dex --dump-to=classes.lst --output=classes.dex \
+    --dump-width=1000 classes
+zip test.jar classes.dex
+
+if [ -r src-ex ]; then
+    mkdir classes-ex
+    ${JAVAC} -d classes-ex -cp classes `find src-ex -name '*.java'`
+    dx -JXmx256m --debug --dex --dump-to=classes-ex.lst \
+        --output=classes-ex.dex --dump-width=1000 classes-ex
+
+    # quick shuffle so that the stored name is "classes.dex"
+    mv classes.dex classes-1.dex
+    mv classes-ex.dex classes.dex
+    zip test-ex.jar classes.dex
+    mv classes.dex classes-ex.dex
+    mv classes-1.dex classes.dex
+fi
diff --git a/test/etc/default-run b/test/etc/default-run
new file mode 100755 (executable)
index 0000000..ecbbbc7
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# 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.
+
+exec ${RUN} "$@"
diff --git a/test/etc/host-run-test-jar b/test/etc/host-run-test-jar
new file mode 100755 (executable)
index 0000000..d3c0fd5
--- /dev/null
@@ -0,0 +1,159 @@
+#!/bin/sh
+#
+# Run the code in test.jar using the host-mode virtual machine. The jar should
+# contain a top-level class named Main to run.
+#
+# Options:
+#   --quiet       -- don't chatter
+#   --fast        -- use the fast interpreter (the default)
+#   --jit         -- use the jit
+#   --portable    -- use the portable interpreter
+#   --debug       -- wait for debugger to attach
+#   --valgrind    -- use valgrind
+#   --no-verify   -- turn off verification (on by default)
+#   --no-optimize -- turn off optimization (on by default)
+
+msg() {
+    if [ "$QUIET" = "n" ]; then
+        echo "$@"
+    fi
+}
+
+INTERP=""
+DEBUG="n"
+GDB="n"
+VERIFY="y"
+OPTIMIZE="y"
+VALGRIND="n"
+DEV_MODE="n"
+QUIET="n"
+PRECISE="y"
+
+while true; do
+    if [ "x$1" = "x--quiet" ]; then
+        QUIET="y"
+        shift
+    elif [ "x$1" = "x--jit" ]; then
+        INTERP="jit"
+        msg "Using jit"
+        shift
+    elif [ "x$1" = "x--fast" ]; then
+        INTERP="fast"
+        msg "Using fast interpreter"
+        shift
+    elif [ "x$1" = "x--portable" ]; then
+        INTERP="portable"
+        msg "Using portable interpreter"
+        shift
+    elif [ "x$1" = "x--debug" ]; then
+        DEBUG="y"
+        shift
+    elif [ "x$1" = "x--gdb" ]; then
+        GDB="y"
+        shift
+    elif [ "x$1" = "x--valgrind" ]; then
+        VALGRIND="y"
+        shift
+    elif [ "x$1" = "x--dev" ]; then
+        DEV_MODE="y"
+        shift
+    elif [ "x$1" = "x--no-verify" ]; then
+        VERIFY="n"
+        shift
+    elif [ "x$1" = "x--no-optimize" ]; then
+        OPTIMIZE="n"
+        shift
+    elif [ "x$1" = "x--no-precise" ]; then
+        PRECISE="n"
+        shift
+    elif [ "x$1" = "x--" ]; then
+        shift
+        break
+    elif expr "x$1" : "x--" >/dev/null 2>&1; then
+        echo "unknown option: $1" 1>&2
+        exit 1
+    else
+        break
+    fi
+done
+
+if [ "x$INTERP" = "x" ]; then
+    INTERP="fast"
+    msg "Using fast interpreter by default"
+fi
+
+if [ "$OPTIMIZE" = "y" ]; then
+    if [ "$VERIFY" = "y" ]; then
+        DEX_OPTIMIZE="-Xdexopt:verified"
+    else
+        DEX_OPTIMIZE="-Xdexopt:all"
+    fi
+    msg "Performing optimizations"
+else
+    DEX_OPTIMIZE="-Xdexopt:none"
+    msg "Skipping optimizations"
+fi
+
+if [ "$VERIFY" = "y" ]; then
+    DEX_VERIFY=""
+    msg "Performing verification"
+else
+    DEX_VERIFY="-Xverify:none"
+    msg "Skipping verification"
+fi
+
+if [ "$VALGRIND" = "y" ]; then
+    msg "Running with valgrind"
+    valgrind_cmd="valgrind"
+    #valgrind_cmd="valgrind --leak-check=full"
+else
+    valgrind_cmd=""
+fi
+
+if [ "$PRECISE" = "y" ]; then
+    GC_OPTS="-Xgc:precise -Xgenregmap"
+else
+    GC_OPTS="-Xgc:noprecise"
+fi
+
+msg "------------------------------"
+
+HOSTBASE="${ANDROID_BUILD_TOP}/out/host"
+BASE="$OUT" # from build environment
+DATA_DIR=/tmp
+DEBUG_OPTS="-Xcheck:jni -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
+
+if [ ! -d $DATA_DIR/dalvik-cache ]; then
+    mkdir -p $DATA_DIR/dalvik-cache
+    [[ $? -ne 0 ]] && exit
+fi
+
+export ANDROID_PRINTF_LOG=brief
+if [ "$DEV_MODE" = "y" ]; then
+    export ANDROID_LOG_TAGS='*:d'
+else
+    export ANDROID_LOG_TAGS='*:s'
+fi
+export ANDROID_DATA="$DATA_DIR"
+export ANDROID_ROOT="${HOSTBASE}/linux-x86"
+export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
+export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
+
+exe="${ANDROID_ROOT}/bin/dalvikvm"
+framework="${BASE}/system/framework"
+bpath="${framework}/core.jar:${framework}/ext.jar:${framework}/framework.jar"
+
+if [ "$DEBUG" = "y" ]; then
+    PORT=8000
+    msg "Waiting for debugger to connect on localhost:$PORT"
+    DEX_DEBUG="-agentlib:jdwp=transport=dt_socket,addres=$PORT,server=y,suspend=y"
+fi
+
+if [ "$GDB" = "y" ]; then
+    gdb=gdb
+    gdbargs="--args $exe"
+fi
+
+$valgrind_cmd $gdb $exe $gdbargs "-Xbootclasspath:${bpath}" \
+    $DEX_VERIFY $DEX_OPTIMIZE $DEX_DEBUG $GC_OPTS "-Xint:${INTERP}" -ea \
+    -cp test.jar Main "$@"
diff --git a/test/etc/push-and-run-test-jar b/test/etc/push-and-run-test-jar
new file mode 100755 (executable)
index 0000000..e2fde42
--- /dev/null
@@ -0,0 +1,135 @@
+#!/bin/sh
+#
+# Run the code in test.jar on the device. The jar should contain a top-level
+# class named Main to run.
+#
+# Options:
+#   --quiet       -- don't chatter
+#   --fast        -- use the fast interpreter (the default)
+#   --jit         -- use the jit
+#   --portable    -- use the portable interpreter
+#   --debug       -- wait for debugger to attach
+#   --zygote      -- use the zygote (if so, all other options are ignored)
+#   --dev         -- development mode (print the vm invocation cmdline)
+#   --no-verify   -- turn off verification (on by default)
+#   --no-optimize -- turn off optimization (on by default)
+#   --no-precise  -- turn off precise GC (on by default)
+
+msg() {
+    if [ "$QUIET" = "n" ]; then
+        echo "$@"
+    fi
+}
+
+INTERP=""
+DEBUG="n"
+VERIFY="y"
+OPTIMIZE="y"
+ZYGOTE="n"
+QUIET="n"
+PRECISE="y"
+DEV_MODE="n"
+
+while true; do
+    if [ "x$1" = "x--quiet" ]; then
+        QUIET="y"
+        shift
+    elif [ "x$1" = "x--fast" ]; then
+        INTERP="fast"
+        msg "Using fast interpreter"
+        shift
+    elif [ "x$1" = "x--jit" ]; then
+        INTERP="jit"
+        msg "Using jit"
+        shift
+    elif [ "x$1" = "x--portable" ]; then
+        INTERP="portable"
+        msg "Using portable interpreter"
+        shift
+    elif [ "x$1" = "x--debug" ]; then
+        DEBUG="y"
+        shift
+    elif [ "x$1" = "x--zygote" ]; then
+        ZYGOTE="y"
+        msg "Spawning from zygote"
+        shift
+    elif [ "x$1" = "x--dev" ]; then
+        DEV_MODE="y"
+        shift
+    elif [ "x$1" = "x--no-verify" ]; then
+        VERIFY="n"
+        shift
+    elif [ "x$1" = "x--no-optimize" ]; then
+        OPTIMIZE="n"
+        shift
+    elif [ "x$1" = "x--no-precise" ]; then
+        PRECISE="n"
+        shift
+    elif [ "x$1" = "x--" ]; then
+        shift
+        break
+    elif expr "x$1" : "x--" >/dev/null 2>&1; then
+        echo "unknown option: $1" 1>&2
+        exit 1
+    else
+        break
+    fi
+done
+
+if [ "$ZYGOTE" = "n" ]; then
+    if [ "x$INTERP" = "x" ]; then
+        INTERP="fast"
+        msg "Using fast interpreter by default"
+    fi
+
+    if [ "$OPTIMIZE" = "y" ]; then
+        if [ "$VERIFY" = "y" ]; then
+            DEX_OPTIMIZE="-Xdexopt:verified"
+        else
+            DEX_OPTIMIZE="-Xdexopt:all"
+        fi
+        msg "Performing optimizations"
+    else
+        DEX_OPTIMIZE="-Xdexopt:none"
+        msg "Skipping optimizations"
+    fi
+
+    if [ "$VERIFY" = "y" ]; then
+        DEX_VERIFY=""
+        msg "Performing verification"
+    else
+        DEX_VERIFY="-Xverify:none"
+        msg "Skipping verification"
+    fi
+fi
+
+msg "------------------------------"
+
+if [ "$QUIET" = "n" ]; then
+    adb push test.jar /data
+    adb push test-ex.jar /data
+else
+    adb push test.jar /data >/dev/null 2>&1
+    adb push test-ex.jar /data >/dev/null 2>&1
+fi
+
+if [ "$DEBUG" = "y" ]; then
+    DEX_DEBUG="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y"
+fi
+
+if [ "$PRECISE" = "y" ]; then
+    GC_OPTS="-Xgc:precise -Xgenregmap"
+else
+    GC_OPTS="-Xgc:noprecise"
+fi
+
+if [ "$ZYGOTE" = "y" ]; then
+    adb shell cd /data \; dvz -classpath test.jar Main "$@"
+else
+    cmdline="cd /data; dalvikvm $DEX_VERIFY $DEX_OPTIMIZE $DEX_DEBUG \
+        $GC_OPTS -cp test.jar -Xint:${INTERP} -ea Main"
+    if [ "$DEV_MODE" = "y" ]; then
+        echo $cmdline "$@"
+    fi
+    adb shell $cmdline "$@"
+fi
diff --git a/test/etc/reference-run-test-classes b/test/etc/reference-run-test-classes
new file mode 100755 (executable)
index 0000000..94c8050
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/sh
+#
+# Run the code in a classes directory on a host-local reference virtual
+# machine. The jar should contain a top-level class named Main to run.
+#
+# Options:
+#   --quiet       -- don't chatter
+#   --debug       -- wait for debugger to attach
+#   --no-verify   -- turn off verification (on by default)
+#   --dev         -- development mode
+
+msg() {
+    if [ "$QUIET" = "n" ]; then
+        echo "$@"
+    fi
+}
+
+DEBUG="n"
+QUIET="n"
+VERIFY="y"
+
+while true; do
+    if [ "x$1" = "x--quiet" ]; then
+        QUIET="y"
+        shift
+    elif [ "x$1" = "x--debug" ]; then
+        DEBUG="y"
+        shift
+    elif [ "x$1" = "x--no-verify" ]; then
+        VERIFY="n"
+        shift
+    elif [ "x$1" = "x--dev" ]; then
+        # not used; ignore
+        shift
+    elif [ "x$1" = "x--" ]; then
+        shift
+        break
+    elif expr "x$1" : "x--" >/dev/null 2>&1; then
+        echo "unknown option: $1" 1>&2
+        exit 1
+    else
+        break
+    fi
+done
+
+if [ "$VERIFY" = "y" ]; then
+    VERIFY_ARG="-Xverify:all"
+    msg "Performing verification"
+else
+    VERIFY_ARG="-Xverify:none"
+    msg "Skipping verification"
+fi
+
+if [ "$DEBUG" = "y" ]; then
+    PORT=8000
+    msg "Waiting for debugger to connect on localhost:$PORT"
+    DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
+fi
+
+${JAVA} ${DEBUG_OPTS} -ea ${VERIFY_ARG} -classpath classes Main "$@"
diff --git a/test/run-all-tests b/test/run-all-tests
new file mode 100755 (executable)
index 0000000..f66cd76
--- /dev/null
@@ -0,0 +1,124 @@
+#!/bin/bash
+#
+# Copyright (C) 2007 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Set up prog to be the path of this script, including following symlinks,
+# and set up progdir to be the fully-qualified pathname of its directory.
+prog="$0"
+while [ -h "${prog}" ]; do
+    newProg=`/bin/ls -ld "${prog}"`
+    newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
+    if expr "x${newProg}" : 'x/' >/dev/null; then
+        prog="${newProg}"
+    else
+        progdir=`dirname "${prog}"`
+        prog="${progdir}/${newProg}"
+    fi
+done
+oldwd=`pwd`
+progdir=`dirname "${prog}"`
+cd "${progdir}"
+progdir=`pwd`
+prog="${progdir}"/`basename "${prog}"`
+
+run_args=""
+usage="no"
+
+while true; do
+    if [ "x$1" = "x--host" ]; then
+        run_args="${run_args} --host"
+        shift
+    elif [ "x$1" = "x--reference" ]; then
+        run_args="${run_args} --reference"
+        shift
+    elif [ "x$1" = "x--jit" ]; then
+        run_args="${run_args} --jit"
+        shift
+    elif [ "x$1" = "x--fast" ]; then
+        run_args="${run_args} --fast"
+        shift
+    elif [ "x$1" = "x--portable" ]; then
+        run_args="${run_args} --portable"
+        shift
+    elif [ "x$1" = "x--debug" ]; then
+        run_args="${run_args} --debug"
+        shift
+    elif [ "x$1" = "x--zygote" ]; then
+        run_args="${run_args} --zygote"
+        shift
+    elif [ "x$1" = "x--no-verify" ]; then
+        run_args="${run_args} --no-verify"
+        shift
+    elif [ "x$1" = "x--no-optimize" ]; then
+        run_args="${run_args} --no-optimize"
+        shift
+    elif [ "x$1" = "x--valgrind" ]; then
+        run_args="${run_args} --valgrind"
+        shift
+    elif [ "x$1" = "x--dev" ]; then
+        run_args="${run_args} --dev"
+        shift
+    elif [ "x$1" = "x--update" ]; then
+        run_args="${run_args} --update"
+        shift
+    elif [ "x$1" = "x--help" ]; then
+        usage="yes"
+        shift
+    elif expr "x$1" : "x--" >/dev/null 2>&1; then
+        echo "unknown option: $1" 1>&2
+        usage="yes"
+        break
+    else
+        break
+    fi
+done
+
+if [ "$usage" = "yes" ]; then
+    prog=`basename $prog`
+    (
+        echo "usage:"
+        echo "  $prog --help     Print this message."
+        echo "  $prog [options]  Run all tests with the given options."
+        echo "  Options are all passed to run-test; refer to that for " \
+             "further documentation:"
+        echo "    --debug --dev --fast --host --no-optimize --no-verify" \
+             "--portable"
+        echo "    --reference --update --valgrind --zygote"
+    ) 1>&2
+    exit 1
+fi
+
+passed=0
+failed=0
+failNames=""
+
+for i in *; do
+    if [ -d "$i" -a -r "$i" -a -r "${i}/info.txt" ]; then
+        ./run-test ${run_args} "$i"
+        if [ "$?" = "0" ]; then
+            ((passed += 1))
+        else
+            ((failed += 1))
+            failNames="$failNames $i"
+        fi
+    fi
+done
+
+echo "passed: $passed test(s)"
+echo "failed: $failed test(s)"
+
+for i in $failNames; do
+    echo "failed: $i"
+done
diff --git a/test/run-test b/test/run-test
new file mode 100755 (executable)
index 0000000..fb758d7
--- /dev/null
@@ -0,0 +1,254 @@
+#!/bin/bash
+#
+# Copyright (C) 2007 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Set up prog to be the path of this script, including following symlinks,
+# and set up progdir to be the fully-qualified pathname of its directory.
+prog="$0"
+while [ -h "${prog}" ]; do
+    newProg=`/bin/ls -ld "${prog}"`
+    newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
+    if expr "x${newProg}" : 'x/' >/dev/null; then
+        prog="${newProg}"
+    else
+        progdir=`dirname "${prog}"`
+        prog="${progdir}/${newProg}"
+    fi
+done
+oldwd=`pwd`
+progdir=`dirname "${prog}"`
+cd "${progdir}"
+progdir=`pwd`
+prog="${progdir}"/`basename "${prog}"`
+
+export JAVA="java"
+export JAVAC="javac -target 1.5"
+export RUN="${progdir}/etc/push-and-run-test-jar"
+
+info="info.txt"
+build="build"
+run="run"
+expected="expected.txt"
+output="output.txt"
+build_output="build-output.txt"
+run_args="--quiet"
+
+dev_mode="no"
+update_mode="no"
+debug_mode="no"
+usage="no"
+
+while true; do
+    if [ "x$1" = "x--host" ]; then
+        RUN="${progdir}/etc/host-run-test-jar"
+        shift
+    elif [ "x$1" = "x--reference" ]; then
+        RUN="${progdir}/etc/reference-run-test-classes"
+        shift
+    elif [ "x$1" = "x--jit" ]; then
+        run_args="${run_args} --jit"
+        shift
+    elif [ "x$1" = "x--fast" ]; then
+        run_args="${run_args} --fast"
+        shift
+    elif [ "x$1" = "x--portable" ]; then
+        run_args="${run_args} --portable"
+        shift
+    elif [ "x$1" = "x--debug" ]; then
+        run_args="${run_args} --debug"
+        shift
+    elif [ "x$1" = "x--gdb" ]; then
+        run_args="${run_args} --gdb"
+        dev_mode="yes"
+        shift
+    elif [ "x$1" = "x--zygote" ]; then
+        run_args="${run_args} --zygote"
+        shift
+    elif [ "x$1" = "x--no-verify" ]; then
+        run_args="${run_args} --no-verify"
+        shift
+    elif [ "x$1" = "x--no-optimize" ]; then
+        run_args="${run_args} --no-optimize"
+        shift
+    elif [ "x$1" = "x--no-precise" ]; then
+        run_args="${run_args} --no-precise"
+        shift
+    elif [ "x$1" = "x--valgrind" ]; then
+        run_args="${run_args} --valgrind"
+        shift
+    elif [ "x$1" = "x--dev" ]; then
+        run_args="${run_args} --dev"
+        dev_mode="yes"
+        shift
+    elif [ "x$1" = "x--update" ]; then
+        update_mode="yes"
+        shift
+    elif [ "x$1" = "x--help" ]; then
+        usage="yes"
+        shift
+    elif expr "x$1" : "x--" >/dev/null 2>&1; then
+        echo "unknown option: $1" 1>&2
+        usage="yes"
+        break
+    else
+        break
+    fi
+done
+
+if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then
+    echo "--dev and --update are mutually exclusive" 1>&2
+    usage="yes"
+fi
+
+if [ "$usage" = "no" ]; then
+    if [ "x$1" = "x" -o "x$1" = "x-" ]; then
+        test_dir=`basename "$oldwd"`
+    else
+        test_dir="$1"
+    fi
+
+    if [ '!' -d "$test_dir" ]; then
+        td2=`echo ${test_dir}-*`
+        if [ '!' -d "$td2" ]; then
+            echo "${test_dir}: no such test directory" 1>&2
+            usage="yes"
+        fi
+        test_dir="$td2"
+    fi
+
+    # Shift to get rid of the test name argument. The rest of the arguments
+    # will get passed to the test run.
+    shift
+fi
+
+if [ "$usage" = "yes" ]; then
+    prog=`basename $prog`
+    (
+        echo "usage:"
+        echo "  $prog --help                          Print this message."
+        echo "  $prog [options] [test-name]           Run test normally."
+        echo "  $prog --dev [options] [test-name]     Development mode" \
+             "(dumps to stdout)."
+        echo "  $prog --update [options] [test-name]  Update mode" \
+             "(replaces expected.txt)."
+        echo '  Omitting the test name or specifying "-" will use the' \
+             "current directory."
+        echo "  Runtime Options:"
+        echo "    --fast         Use the fast interpreter (the default)."
+        echo "    --jit          Use the jit."
+        echo "    --portable     Use the portable interpreter."
+        echo "    --debug        Wait for a debugger to attach."
+        #echo "    --gdb          Run under gdb; incompatible with some tests."
+        echo "    --no-verify    Turn off verification (on by default)."
+        echo "    --no-optimize  Turn off optimization (on by default)."
+        echo "    --no-precise   Turn off precise GC (on by default)."
+        echo "    --zygote       Spawn the process from the Zygote." \
+             "If used, then the"
+        echo "                   other runtime options are ignored."
+        echo "    --host         Use the host-mode virtual machine."
+        echo "    --valgrind     Use valgrind when running locally."
+        echo "    --reference    Use a host-local reference virtual machine."
+    ) 1>&2
+    exit 1
+fi
+
+cd "$test_dir"
+test_dir=`pwd`
+
+td_info="${test_dir}/${info}"
+td_expected="${test_dir}/${expected}"
+
+tmp_dir="/tmp/test-$$"
+
+if [ '!' '(' -r "$td_info" -a -r "$td_expected" ')' ]; then
+    echo "${test_dir}: missing files" 1>&2
+    exit 1
+fi
+
+# copy the test to a temp dir and run it
+
+echo "${test_dir}: running..." 1>&2
+
+rm -rf "$tmp_dir"
+cp -Rp "$test_dir" "$tmp_dir"
+cd "$tmp_dir"
+
+if [ '!' -r "$build" ]; then
+    cp "${progdir}/etc/default-build" build
+fi
+
+if [ '!' -r "$run" ]; then
+    cp "${progdir}/etc/default-run" run
+fi
+
+chmod 755 "$build"
+chmod 755 "$run"
+
+good="no"
+if [ "$dev_mode" = "yes" ]; then
+    "./${build}" 2>&1
+    echo "build exit status: $?" 1>&2
+    "./${run}" $run_args "$@" 2>&1
+    echo "run exit status: $?" 1>&2
+    good="yes"
+elif [ "$update_mode" = "yes" ]; then
+    "./${build}" >"$build_output" 2>&1
+    build_exit="$?"
+    if [ "$build_exit" = '0' ]; then
+        "./${run}" $run_args "$@" >"$output" 2>&1
+        sed -e 's/[[:cntrl:]]$//g' < "$output" >"${td_expected}"
+        good="yes"
+    else
+        cat "$build_output" 1>&2
+        echo "build exit status: $build_exit" 1>&2
+    fi
+else
+    "./${build}" >"$build_output" 2>&1
+    build_exit="$?"
+    if [ "$build_exit" = '0' ]; then
+        "./${run}" $run_args "$@" >"$output" 2>&1
+    else
+        cp "$build_output" "$output"
+        echo "build exit status: $build_exit" >>"$output"
+    fi
+    diff --strip-trailing-cr -q "$expected" "$output" >/dev/null
+    if [ "$?" = "0" ]; then
+        # output == expected
+        good="yes"
+        echo "${test_dir}: succeeded!" 1>&2
+    fi
+fi
+
+if [ "$good" = "yes" ]; then
+    cd "$oldwd"
+    rm -rf "$tmp_dir"
+    exit 0
+fi
+
+(
+    if [ "$update_mode" '!=' "yes" ]; then
+        echo "${test_dir}: FAILED!"
+        echo ' '
+        echo '#################### info'
+        cat "${td_info}" | sed 's/^/# /g'
+        echo '#################### diffs'
+        diff --strip-trailing-cr -u "$expected" "$output"
+        echo '####################'
+        echo ' '
+    fi
+    echo "files left in ${tmp_dir}"
+) 1>&2
+
+exit 1