diff --git a/Android.bp b/Android.bp index b1b332a9a2b5379dda82f01c9a77d05a8d988adb..a507465aa419509b4ed1f20d341b75e8f2c3fea4 100644 --- a/Android.bp +++ b/Android.bp @@ -64,6 +64,7 @@ filegroup { srcs: [ // Java/AIDL sources under frameworks/base ":framework-annotations", + ":ravenwood-annotations", ":framework-blobstore-sources", ":framework-core-sources", ":framework-drm-sources", @@ -284,6 +285,7 @@ java_defaults { enforce_permissions_exceptions: [ // Do not add entries to this list. ":framework-annotations", + ":ravenwood-annotations", ":framework-blobstore-sources", ":framework-core-sources", ":framework-drm-sources", @@ -409,7 +411,6 @@ java_defaults { "audiopolicy-aidl-java", "sounddose-aidl-java", "modules-utils-expresslog", - "hoststubgen-annotations", ], } @@ -838,4 +839,5 @@ build = [ "AconfigFlags.bp", "ProtoLibraries.bp", "TestProtoLibraries.bp", + "Ravenwood.bp", ] diff --git a/OWNERS b/OWNERS index 4e5c7d8eacbf255496ed908c07501ead1a30db59..023bdeff34fee5f45fe8af42f5ecdd34cfdf43f2 100644 --- a/OWNERS +++ b/OWNERS @@ -34,3 +34,6 @@ per-file TestProtoLibraries.bp = file:platform/tools/tradefederation:/OWNERS per-file ZYGOTE_OWNERS = file:/ZYGOTE_OWNERS per-file SQLITE_OWNERS = file:/SQLITE_OWNERS + +per-file *ravenwood* = file:ravenwood/OWNERS +per-file *Ravenwood* = file:ravenwood/OWNERS diff --git a/Ravenwood.bp b/Ravenwood.bp new file mode 100644 index 0000000000000000000000000000000000000000..9218cc9bc3f856b11af769525afe44e800886c9d --- /dev/null +++ b/Ravenwood.bp @@ -0,0 +1,70 @@ +// Copyright (C) 2023 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. + +// We need this "trampoline" rule to force soong to give a host-side jar to +// framework-minus-apex.ravenwood. Otherwise, soong would mix up the arch (?) and we'd get +// a dex jar. +java_library { + name: "framework-minus-apex-for-hoststubgen", + installable: false, // host only jar. + static_libs: [ + "framework-minus-apex", + ], + sdk_version: "core_platform", + visibility: ["//visibility:private"], +} + +// Generate the stub/impl from framework-all, with hidden APIs. +java_genrule_host { + name: "framework-minus-apex.ravenwood-base", + tools: ["hoststubgen"], + cmd: "$(location hoststubgen) " + + "@$(location :ravenwood-standard-options) " + + + "--out-stub-jar $(location ravenwood_stub.jar) " + + "--out-impl-jar $(location ravenwood.jar) " + + + "--gen-keep-all-file $(location hoststubgen_keep_all.txt) " + + "--gen-input-dump-file $(location hoststubgen_dump.txt) " + + + "--in-jar $(location :framework-minus-apex-for-hoststubgen) " + + "--policy-override-file $(location framework-minus-apex-ravenwood-policies.txt) ", + srcs: [ + ":framework-minus-apex-for-hoststubgen", + "framework-minus-apex-ravenwood-policies.txt", + ":ravenwood-standard-options", + ], + out: [ + "ravenwood.jar", + "ravenwood_stub.jar", // It's not used. TODO: Update hoststubgen to make it optional. + + // Following files are created just as FYI. + "hoststubgen_keep_all.txt", + "hoststubgen_dump.txt", + ], + visibility: ["//visibility:private"], +} + +// Extract the impl jar from "framework-minus-apex.ravenwood-base" for subsequent build rules. +java_genrule_host { + name: "framework-minus-apex.ravenwood", + cmd: "cp $(in) $(out)", + srcs: [ + ":framework-minus-apex.ravenwood-base{ravenwood.jar}", + ], + out: [ + "framework-minus-apex.ravenwood.jar", + ], + visibility: ["//visibility:public"], +} diff --git a/core/java/android/util/Base64.java b/core/java/android/util/Base64.java index 92abd7c15f5fde47a0f27678c1c85e7348a2460a..33cc5e37da625fb4d9a825cb190ce38c5486965b 100644 --- a/core/java/android/util/Base64.java +++ b/core/java/android/util/Base64.java @@ -26,6 +26,7 @@ import java.io.UnsupportedEncodingException; * href="http://www.ietf.org/rfc/rfc2045.txt">2045</a> and <a * href="http://www.ietf.org/rfc/rfc3548.txt">3548</a>. */ +@android.ravenwood.annotations.RavenwoodWholeClassKeep public class Base64 { /** * Default values for encoder/decoder flags. diff --git a/framework-minus-apex-ravenwood-policies.txt b/framework-minus-apex-ravenwood-policies.txt new file mode 100644 index 0000000000000000000000000000000000000000..6bac58bf8ed7a0ad9d5f91900ed0e5d888125d78 --- /dev/null +++ b/framework-minus-apex-ravenwood-policies.txt @@ -0,0 +1 @@ +# Ravenwood "policy" file for framework-minus-apex. diff --git a/ravenwood/Android.bp b/ravenwood/Android.bp new file mode 100644 index 0000000000000000000000000000000000000000..91acc3d0deb423de6788919f80dfa97cf4737834 --- /dev/null +++ b/ravenwood/Android.bp @@ -0,0 +1,33 @@ +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "frameworks_base_license" + // to get the below license kinds: + // SPDX-license-identifier-Apache-2.0 + default_applicable_licenses: ["frameworks_base_license"], +} + +filegroup { + name: "ravenwood-annotations", + srcs: [ + "annotations-src/**/*.java", + ], + visibility: ["//visibility:public"], +} + +// File that contains the standard command line arguments to hoststubgen. +filegroup { + name: "ravenwood-standard-options", + srcs: [ + "ravenwood-standard-options.txt", + ], + visibility: ["//visibility:public"], +} + +java_library { + name: "ravenwood-annotations-lib", + srcs: [":ravenwood-annotations"], + sdk_version: "core_current", + host_supported: true, + visibility: ["//visibility:public"], +} diff --git a/ravenwood/OWNERS b/ravenwood/OWNERS new file mode 100644 index 0000000000000000000000000000000000000000..c06b3b9c2d1118f528d670ac73f61a98c567e158 --- /dev/null +++ b/ravenwood/OWNERS @@ -0,0 +1,3 @@ +jsharkey@google.com +omakoto@google.com +jaggies@google.com diff --git a/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodClassLoadHook.java b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodClassLoadHook.java new file mode 100644 index 0000000000000000000000000000000000000000..be7b923244bf5ed2ac501915cb45cf2e29a28c2b --- /dev/null +++ b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodClassLoadHook.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 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 android.ravenwood.annotations; + +import static java.lang.annotation.ElementType.TYPE; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * THIS ANNOTATION IS EXPERIMENTAL. REACH OUT TO g/ravenwood BEFORE USING IT, OR YOU HAVE ANY + * QUESTIONS ABOUT IT. + * + * Add this with a fully-specified method name (e.g. {@code "com.package.Class.methodName"}) + * of a callback to get a callback at the class load time. + * + * The method must be {@code public static} with a single argument that takes + * {@link Class}. + */ +@Target({TYPE}) +@Retention(RetentionPolicy.CLASS) +public @interface RavenwoodClassLoadHook { + String value(); +} diff --git a/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodKeep.java b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodKeep.java new file mode 100644 index 0000000000000000000000000000000000000000..1644ffc57dca7a4ebbb0e87cc7cd37c11f330b55 --- /dev/null +++ b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodKeep.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 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 android.ravenwood.annotations; + +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * THIS ANNOTATION IS EXPERIMENTAL. REACH OUT TO g/ravenwood BEFORE USING IT, OR YOU HAVE ANY + * QUESTIONS ABOUT IT. + * + * TODO: Javadoc + * + */ +@Target({TYPE, FIELD, METHOD, CONSTRUCTOR}) +@Retention(RetentionPolicy.CLASS) +public @interface RavenwoodKeep { +} diff --git a/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodNativeSubstitutionClass.java b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodNativeSubstitutionClass.java new file mode 100644 index 0000000000000000000000000000000000000000..eb883e228a40aed2f7882b11223e0639ded182ef --- /dev/null +++ b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodNativeSubstitutionClass.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 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 android.ravenwood.annotations; + +import static java.lang.annotation.ElementType.TYPE; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * THIS ANNOTATION IS EXPERIMENTAL. REACH OUT TO g/ravenwood BEFORE USING IT, OR YOU HAVE ANY + * QUESTIONS ABOUT IT. + * + * TODO: Javadoc + */ +@Target({TYPE}) +@Retention(RetentionPolicy.CLASS) +public @interface RavenwoodNativeSubstitutionClass { + String value(); +} diff --git a/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodRemove.java b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodRemove.java new file mode 100644 index 0000000000000000000000000000000000000000..ffa1fa50fa4e0669a1957527fb7c24025e47fe20 --- /dev/null +++ b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodRemove.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 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 android.ravenwood.annotations; + +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * THIS ANNOTATION IS EXPERIMENTAL. REACH OUT TO g/ravenwood BEFORE USING IT, OR YOU HAVE ANY + * QUESTIONS ABOUT IT. + * + * TODO: Javadoc + */ +@Target({TYPE, FIELD, METHOD, CONSTRUCTOR}) +@Retention(RetentionPolicy.CLASS) +public @interface RavenwoodRemove { +} diff --git a/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodSubstitute.java b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodSubstitute.java new file mode 100644 index 0000000000000000000000000000000000000000..6d747da102071f56b04a6a69ca639540a84b5dcd --- /dev/null +++ b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodSubstitute.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 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 android.ravenwood.annotations; + +import static java.lang.annotation.ElementType.METHOD; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * THIS ANNOTATION IS EXPERIMENTAL. REACH OUT TO g/ravenwood BEFORE USING IT, OR YOU HAVE ANY + * QUESTIONS ABOUT IT. + * + * TODO: Javadoc + */ +@Target({METHOD}) +@Retention(RetentionPolicy.CLASS) +public @interface RavenwoodSubstitute { + // TODO We should add "_host" as default. We're not doing it yet, because extractign the default + // value with ASM doesn't seem trivial. (? not sure.) + String suffix(); +} diff --git a/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodThrow.java b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodThrow.java new file mode 100644 index 0000000000000000000000000000000000000000..a329d841abbe24a8e941db40b1d5ff15bdf55c47 --- /dev/null +++ b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodThrow.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2023 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 android.ravenwood.annotations; + +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.METHOD; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * THIS ANNOTATION IS EXPERIMENTAL. REACH OUT TO g/ravenwood BEFORE USING IT, OR YOU HAVE ANY + * QUESTIONS ABOUT IT. + * + * TODO: Javadoc + * TODO: Create "whole-class-throw"? + */ +@Target({METHOD, CONSTRUCTOR}) +@Retention(RetentionPolicy.CLASS) +public @interface RavenwoodThrow { +} diff --git a/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodWholeClassKeep.java b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodWholeClassKeep.java new file mode 100644 index 0000000000000000000000000000000000000000..ae6f42dbeaa6ad9e2042adcae20bb6a3ce56d4e2 --- /dev/null +++ b/ravenwood/annotations-src/android/ravenwood/annotations/RavenwoodWholeClassKeep.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 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 android.ravenwood.annotations; + +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * THIS ANNOTATION IS EXPERIMENTAL. REACH OUT TO g/ravenwood BEFORE USING IT, OR YOU HAVE ANY + * QUESTIONS ABOUT IT. + * + * TODO: Javadoc + * TODO: Create "whole-class-throw"? + */ +@Target({TYPE, FIELD, METHOD, CONSTRUCTOR}) +@Retention(RetentionPolicy.CLASS) +public @interface RavenwoodWholeClassKeep { +} diff --git a/ravenwood/ravenwood-standard-options.txt b/ravenwood/ravenwood-standard-options.txt new file mode 100644 index 0000000000000000000000000000000000000000..6e1384f368b8eb37898ea05d503001926412bbbb --- /dev/null +++ b/ravenwood/ravenwood-standard-options.txt @@ -0,0 +1,37 @@ +# File containing standard options to HostStubGen for Ravenwood + +--debug + +# Keep all classes / methods / fields, but make the methods throw. +--default-throw + +# Uncomment below lines to enable each feature. +# --enable-non-stub-method-check + +#--default-method-call-hook +# com.android.hoststubgen.hosthelper.HostTestUtils.logMethodCall +#--default-class-load-hook +# com.android.hoststubgen.hosthelper.HostTestUtils.logClassLoaded + +# Standard annotations. +# Note, each line is a single argument, so we need newlines after each `--xxx-annotation`. +--keep-annotation + android.ravenwood.annotations.RavenwoodKeep + +--keep-class-annotation + android.ravenwood.annotations.RavenwoodWholeClassKeep + +--throw-annotation + android.ravenwood.annotations.RavenwoodThrow + +--remove-annotation + android.ravenwood.annotations.RavenwoodRemove + +--substitute-annotation + android.ravenwood.annotations.RavenwoodSubstitute + +--native-substitute-annotation + android.ravenwood.annotations.RavenwoodNativeSubstitutionClass + +--class-load-hook-annotation + android.ravenwood.annotations.RavenwoodClassLoadHook diff --git a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/ConstantFilter.kt b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/ConstantFilter.kt index 33010baaf894b00680ec71e062f570ad683be39e..678e6eae0be63db927518bd9e0ae9d4cb8b78d37 100644 --- a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/ConstantFilter.kt +++ b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/ConstantFilter.kt @@ -46,8 +46,11 @@ class ConstantFilter( } methodPolicy = policy - // TODO: Need to think about the realistic default behavior. - classPolicy = if (policy != FilterPolicy.Throw) policy else FilterPolicy.Remove + // If the default policy is "throw", we convert it to "keep" for classes and fields. + classPolicy = when (policy) { + FilterPolicy.Throw -> FilterPolicy.Keep + else -> policy + } fieldPolicy = classPolicy } diff --git a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/ImplicitOutputFilter.kt b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/ImplicitOutputFilter.kt index 9c372ff68e37f01acf23a2b0df3a5e1c1ff313b5..c6334c40e8f42e69e0b54dfb91c347edebd44a04 100644 --- a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/ImplicitOutputFilter.kt +++ b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/ImplicitOutputFilter.kt @@ -17,6 +17,8 @@ package com.android.hoststubgen.filters import com.android.hoststubgen.HostStubGenErrors import com.android.hoststubgen.HostStubGenInternalException +import com.android.hoststubgen.asm.CLASS_INITIALIZER_DESC +import com.android.hoststubgen.asm.CLASS_INITIALIZER_NAME import com.android.hoststubgen.asm.isAnonymousInnerClass import com.android.hoststubgen.log import com.android.hoststubgen.asm.ClassNodes @@ -81,6 +83,16 @@ class ImplicitOutputFilter( } } + // If we throw from the static initializer, the class would be useless, so we convert it + // "keep" instead. + if (methodName == CLASS_INITIALIZER_NAME && descriptor == CLASS_INITIALIZER_DESC && + fallback.policy == FilterPolicy.Throw) { + // TODO Maybe show a warning?? But that'd be too noisy with --default-throw. + return FilterPolicy.Keep.withReason( + "'throw' on static initializer is handled as 'keep'" + + " [original throw reason: ${fallback.reason}]") + } + return fallback } } \ No newline at end of file diff --git a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/visitors/ImplGeneratingAdapter.kt b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/visitors/ImplGeneratingAdapter.kt index 57b668954f9852ad77a584b18845415d214664ce..ce72a8e7988242b8daeae5e19fbe23f764391c5b 100644 --- a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/visitors/ImplGeneratingAdapter.kt +++ b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/visitors/ImplGeneratingAdapter.kt @@ -79,7 +79,7 @@ class ImplGeneratingAdapter( // StaticInitMerger will merge it with the existing one, if any. visitMethod( Opcodes.ACC_PRIVATE or Opcodes.ACC_STATIC, - "<clinit>", + CLASS_INITIALIZER_NAME, "()V", null, null diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/02-hoststubgen-test-tiny-framework-host-stub-dump.txt b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/02-hoststubgen-test-tiny-framework-host-stub-dump.txt index 43ceec42660defccb3b1360914dc595400d07564..0761edc34916e887fc6108b87be053ca123cd5f0 100644 --- a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/02-hoststubgen-test-tiny-framework-host-stub-dump.txt +++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/02-hoststubgen-test-tiny-framework-host-stub-dump.txt @@ -372,7 +372,7 @@ public class com.android.hoststubgen.test.tinyframework.TinyFrameworkClassWithIn flags: (0x0021) ACC_PUBLIC, ACC_SUPER this_class: #x // com/android/hoststubgen/test/tinyframework/TinyFrameworkClassWithInitializer super_class: #x // java/lang/Object - interfaces: 0, fields: 1, methods: 2, attributes: 3 + interfaces: 0, fields: 1, methods: 1, attributes: 3 public static boolean sInitialized; descriptor: Z flags: (0x0009) ACC_PUBLIC, ACC_STATIC @@ -387,17 +387,6 @@ public class com.android.hoststubgen.test.tinyframework.TinyFrameworkClassWithIn x: ldc #x // String Stub! x: invokespecial #x // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V x: athrow - - static {}; - descriptor: ()V - flags: (0x0008) ACC_STATIC - Code: - stack=3, locals=0, args_size=0 - x: new #x // class java/lang/RuntimeException - x: dup - x: ldc #x // String Stub! - x: invokespecial #x // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V - x: athrow } SourceFile: "TinyFrameworkClassWithInitializer.java" RuntimeVisibleAnnotations: diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/12-hoststubgen-test-tiny-framework-host-ext-stub-dump.txt b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/12-hoststubgen-test-tiny-framework-host-ext-stub-dump.txt index 43ceec42660defccb3b1360914dc595400d07564..0761edc34916e887fc6108b87be053ca123cd5f0 100644 --- a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/12-hoststubgen-test-tiny-framework-host-ext-stub-dump.txt +++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/12-hoststubgen-test-tiny-framework-host-ext-stub-dump.txt @@ -372,7 +372,7 @@ public class com.android.hoststubgen.test.tinyframework.TinyFrameworkClassWithIn flags: (0x0021) ACC_PUBLIC, ACC_SUPER this_class: #x // com/android/hoststubgen/test/tinyframework/TinyFrameworkClassWithInitializer super_class: #x // java/lang/Object - interfaces: 0, fields: 1, methods: 2, attributes: 3 + interfaces: 0, fields: 1, methods: 1, attributes: 3 public static boolean sInitialized; descriptor: Z flags: (0x0009) ACC_PUBLIC, ACC_STATIC @@ -387,17 +387,6 @@ public class com.android.hoststubgen.test.tinyframework.TinyFrameworkClassWithIn x: ldc #x // String Stub! x: invokespecial #x // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V x: athrow - - static {}; - descriptor: ()V - flags: (0x0008) ACC_STATIC - Code: - stack=3, locals=0, args_size=0 - x: new #x // class java/lang/RuntimeException - x: dup - x: ldc #x // String Stub! - x: invokespecial #x // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V - x: athrow } SourceFile: "TinyFrameworkClassWithInitializer.java" RuntimeVisibleAnnotations: diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/policy-override-tiny-framework.txt b/tools/hoststubgen/hoststubgen/test-tiny-framework/policy-override-tiny-framework.txt index 079d2a84e4988a025a5646bb4c2978d8664f6951..8fcd2fbe7c84fbac1fd5f33b7087549e3c65772e 100644 --- a/tools/hoststubgen/hoststubgen/test-tiny-framework/policy-override-tiny-framework.txt +++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/policy-override-tiny-framework.txt @@ -15,3 +15,8 @@ class com/android/hoststubgen/test/tinyframework/TinyFrameworkForTextPolicy stub # Class load hook class com/android/hoststubgen/test/tinyframework/TinyFrameworkForTextPolicy ~com.android.hoststubgen.test.tinyframework.TinyFrameworkClassLoadHook.onClassLoaded + + +class com.android.hoststubgen.test.tinyframework.TinyFrameworkClassWithInitializer stubclass + # Testing 'throw' on a static initializer. This should be handled as 'keep'. + method <clinit> ()V throw diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/run-test-manually.sh b/tools/hoststubgen/hoststubgen/test-tiny-framework/run-test-manually.sh index fd486468a1a70717f01f30636d8ed2911049e9b9..722905f15b417f9675fce2573813d01520e26c9a 100755 --- a/tools/hoststubgen/hoststubgen/test-tiny-framework/run-test-manually.sh +++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/run-test-manually.sh @@ -16,6 +16,10 @@ source "${0%/*}"/../../common.sh +#********************************************************************************************** +#This script is broken because it relies on soong intermediate files, which seem to have moved. +#********************************************************************************************** + # This scripts run the "tiny-framework" test, but does most stuff from the command line, using # the native java and javac commands. # This is useful to @@ -57,7 +61,7 @@ framework_compile_classpaths=( test_compile_classpaths=( $SOONG_INT/external/junit/junit/android_common/combined/junit.jar - $SOONG_INT/prebuilts/tools/common/m2/truth-prebuilt/android_common/combined/truth-prebuilt.jar + $ANDROID_BUILD_TOP/out/target/common/obj/JAVA_LIBRARIES/truth-prebuilt_intermediates/classes.jar ) test_runtime_classpaths=( diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-framework/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkClassWithInitializer.java b/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-framework/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkClassWithInitializer.java index 53cfdf6cd41250442f014c551e73188298009a7c..01a690b73ba03ff92fa28ed4b2e1cd718ebdd112 100644 --- a/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-framework/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkClassWithInitializer.java +++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-framework/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkClassWithInitializer.java @@ -18,10 +18,14 @@ package com.android.hoststubgen.test.tinyframework; import android.hosttest.annotation.HostSideTestClassLoadHook; import android.hosttest.annotation.HostSideTestWholeClassStub; + +// Note, policy-override-tiny-framework.txt hss an override on this class. @HostSideTestClassLoadHook( "com.android.hoststubgen.test.tinyframework.TinyFrameworkClassLoadHook.onClassLoaded") @HostSideTestWholeClassStub public class TinyFrameworkClassWithInitializer { + // Note, this method has a 'throw' in the policy file, which is handled as a 'keep' (because + // it's a static initializer), so this won't show up in the stub jar. static { sInitialized = true; } diff --git a/tools/hoststubgen/scripts/run-all-tests.sh b/tools/hoststubgen/scripts/run-all-tests.sh index 7600942c99e64c9e8227b8118850d2d3c0ade338..2e9cf428354acca312bfb63478bc37561487c739 100755 --- a/tools/hoststubgen/scripts/run-all-tests.sh +++ b/tools/hoststubgen/scripts/run-all-tests.sh @@ -33,7 +33,9 @@ run m run-ravenwood-test ${READY_TEST_MODULES[*]} ${NOT_READY_TEST_MODULES[*]} run ./hoststubgen/test-tiny-framework/diff-and-update-golden.sh run ./hoststubgen/test-framework/run-test-without-atest.sh -run ./hoststubgen/test-tiny-framework/run-test-manually.sh + +#This script is broken because it relies on soong intermediate files, which seem to have moved. +#run ./hoststubgen/test-tiny-framework/run-test-manually.sh run atest tiny-framework-dump-test run ./scripts/build-framework-hostside-jars-and-extract.sh