Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0622dd1c authored by Makoto Onuki's avatar Makoto Onuki
Browse files

HostStubGen: Inject more annotations in output jar

Now we inject 5 annotations:
HostStubGenKeptInImpl
HostStubGenKeptInStub

HostStubGenProcessedAsIgnore
HostStubGenProcessedAsSubstitute
HostStubGenProcessedAsThrow

Bug: 311174191
Test: ./scripts/run-all-tests.sh
Change-Id: I9bf399bfdb789bc95be77fe51cd1579358e2dcee
parent fd5e8197
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
/*
 * 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 com.android.hoststubgen.hosthelper;

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;

/**
 * Annotation injected to all classes/methods/fields that are kept in the "impl" jar.
 */
@Target({TYPE, METHOD, CONSTRUCTOR, FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface HostStubGenKeptInImpl {
    String CLASS_INTERNAL_NAME = HostTestUtils.getInternalName(HostStubGenKeptInImpl.class);
    String CLASS_DESCRIPTOR = "L" + CLASS_INTERNAL_NAME + ";";
}
+38 −0
Original line number Diff line number Diff line
/*
 * 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 com.android.hoststubgen.hosthelper;

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;

/**
 * Annotation injected to all classes/methods/fields that are kept in the "stub" jar.
 *
 * All items in the stub jar are automatically kept in the impl jar as well, so
 * the items with this annotation will all have {@link HostStubGenKeptInImpl} too.
 */
@Target({TYPE, METHOD, CONSTRUCTOR, FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface HostStubGenKeptInStub {
    String CLASS_INTERNAL_NAME = HostTestUtils.getInternalName(HostStubGenKeptInStub.class);
    String CLASS_DESCRIPTOR = "L" + CLASS_INTERNAL_NAME + ";";
}
+7 −5
Original line number Diff line number Diff line
@@ -15,18 +15,20 @@
 */
package com.android.hoststubgen.hosthelper;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.ElementType.METHOD;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Annotation added to all "stub" classes generated by HostStubGen.
 * Annotation injected to all methods processed as "ignore".
 *
 * (This annotation is only added in the impl jar, but not the stub jar)
 */
@Target({TYPE})
@Target({METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface HostStubGenProcessedKeepClass {
    String CLASS_INTERNAL_NAME = HostTestUtils.getInternalName(HostStubGenProcessedKeepClass.class);
public @interface HostStubGenProcessedAsIgnore {
    String CLASS_INTERNAL_NAME = HostTestUtils.getInternalName(HostStubGenProcessedAsIgnore.class);
    String CLASS_DESCRIPTOR = "L" + CLASS_INTERNAL_NAME + ";";
}
+38 −0
Original line number Diff line number Diff line
/*
 * 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 com.android.hoststubgen.hosthelper;

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;

/**
 * Annotation injected to all methods that are processed as "substitute".
 *
 * (This annotation is only added in the impl jar, but not the stub jar)
 */
@Target({TYPE, METHOD, CONSTRUCTOR, FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface HostStubGenProcessedAsSubstitute {
    String CLASS_INTERNAL_NAME = HostTestUtils.getInternalName(
            HostStubGenProcessedAsSubstitute.class);
    String CLASS_DESCRIPTOR = "L" + CLASS_INTERNAL_NAME + ";";
}
+7 −5
Original line number Diff line number Diff line
@@ -15,18 +15,20 @@
 */
package com.android.hoststubgen.hosthelper;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.ElementType.METHOD;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Annotation added to all "stub" classes generated by HostStubGen.
 * Annotation injected to all methods that are processed as "throw".
 *
 * (This annotation is only added in the impl jar, but not the stub jar)
 */
@Target({TYPE})
@Target({METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface HostStubGenProcessedStubClass {
    String CLASS_INTERNAL_NAME = HostTestUtils.getInternalName(HostStubGenProcessedStubClass.class);
public @interface HostStubGenProcessedAsThrow {
    String CLASS_INTERNAL_NAME = HostTestUtils.getInternalName(HostStubGenProcessedAsThrow.class);
    String CLASS_DESCRIPTOR = "L" + CLASS_INTERNAL_NAME + ";";
}
Loading