Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 176
RFC for API 102#62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Merged
RFC for API 102 #62
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
42b0c03
Add hot reload API (WIP)
Dr-TSNG cee9357
Call onModuleLoaded by default
Dr-TSNG f84db03
Improve hot reloading spec
Dr-TSNG 4d7ae3c
Add lint check for api versions
Dr-TSNG 3d9555d
Update spec
Dr-TSNG 1882bd9
Update dependencies
Dr-TSNG f2afe1e
Add dontwarn io.github.libxposed.annotation rule
Dr-TSNG ff9eddf
Add snapshots
Dr-TSNG 69fdee5
Add detach api
Dr-TSNG 26a503b
Move detach to XposedInterfaceWrapper
Dr-TSNG bdc6098
Improve docs
Dr-TSNG 1cdde90
Fix typo
Dr-TSNG 3a5ec79
Strongly prevent saving objects created by old module classloader
Dr-TSNG 3201d41
Update README.md
Dr-TSNG fa3c1d9
Update docs
Dr-TSNG a0d7c7a
docs: clarify hot reload lifecycle ownership
Dr-TSNG e11625f
Update docs
Dr-TSNG ad410e1
Remove PROP_RT_HOT_RELOAD
Dr-TSNG 6241491
Delete duplicate doc
vvb2060 0e97f40
Update
Dr-TSNG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| name: Publish Sonatype Snapshot | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| dependency_snapshot: | ||
| description: 'Use snapshot annotation and lint dependencies' | ||
| type: boolean | ||
| default: false | ||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: 'recursive' | ||
| fetch-depth: 0 | ||
| - name: set up JDK | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '21' | ||
| distribution: 'temurin' | ||
| cache: gradle | ||
| - name: Publish snapshot to Sonatype | ||
| run: | | ||
| echo 'org.gradle.caching=true' >> gradle.properties | ||
| echo 'org.gradle.parallel=true' >> gradle.properties | ||
| echo 'org.gradle.vfs.watch=true' >> gradle.properties | ||
| echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties | ||
| echo 'publishSnapshot=true' >> gradle.properties | ||
| echo 'dependencySnapshot=${{ github.event.inputs.dependency_snapshot }}' >> gradle.properties | ||
| ./gradlew publishApiPublicationToSnapshotsRepository | ||
| ./gradlew --stop | ||
| env: | ||
| ORG_GRADLE_PROJECT_signingKey: ${{ secrets.maven_pgp_signingKey }} | ||
| ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.maven_pgp_signingPassword }} | ||
| ORG_GRADLE_PROJECT_snapshotsUsername: ${{ secrets.OSSRHUSERNAME }} | ||
| ORG_GRADLE_PROJECT_snapshotsPassword: ${{ secrets.OSSRHPASSWORD }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 67 additions & 5 deletions
72 api/src/main/java/io/github/libxposed/api/XposedInterface.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 50 additions & 4 deletions
54 api/src/main/java/io/github/libxposed/api/XposedInterfaceWrapper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -12,24 +12,32 @@ | ||
| import java.lang.reflect.Executable; | ||
| import java.lang.reflect.Method; | ||
| import io.github.libxposed.annotation.InternalApi; | ||
| import io.github.libxposed.annotation.SinceApi; | ||
| /** | ||
| * Wrapper of {@link XposedInterface} used by modules to shield framework implementation details. | ||
| */ | ||
| public class XposedInterfaceWrapper implements XposedInterface { | ||
| private volatile XposedInterface mBase; | ||
| private XposedInterface mBase; | ||
| private Runnable mDetachImpl; | ||
Dr-TSNG marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| /** | ||
| * Attaches the framework interface to the module. Modules should never call this method. | ||
| * Attaches the framework interface to the module. Modules <b>must not</b> call this method. | ||
| * It is reserved for framework implementations and may change without compatibility guarantees. | ||
| * | ||
| * @param base The framework interface | ||
| * @param base The framework interface | ||
| * @param detachImpl The implementation of {@link #detach()} | ||
| */ | ||
| @InternalApi | ||
| @SuppressWarnings("unused") | ||
| public final void attachFramework(@NonNull XposedInterface base) { | ||
| public final void attachFramework(@NonNull XposedInterface base, @NonNull Runnable detachImpl) { | ||
| if (mBase != null) { | ||
| throw new IllegalStateException("Framework already attached"); | ||
| } | ||
| mBase = base; | ||
| mDetachImpl = detachImpl; | ||
| } | ||
| private void ensureAttached() { | ||
| @@ -38,6 +46,44 @@ private void ensureAttached() { | ||
| } | ||
| } | ||
| /** | ||
| * Stops all subsequent lifecycle callbacks for the <b>current module entry</b> in the current | ||
| * process. After this method is called, the framework removes its reference to the entry | ||
| * instance and will no longer invoke any lifecycle callbacks (such as | ||
| * {@link XposedModuleInterface#onPackageLoaded}, | ||
| * {@link XposedModuleInterface#onHotReloading}, etc.) on the entry instance that | ||
| * called this method. Only lifecycle callbacks are affected; all {@link XposedInterface} APIs | ||
| * remain fully functional. | ||
| * | ||
| * <p>If the module declares multiple entry classes, only the entry that calls this method is | ||
| * affected. Other entries continue to receive their lifecycle callbacks as normal.</p> | ||
| * | ||
| * <p>This method is idempotent. Calling it multiple times has the same effect as calling it once.</p> | ||
| * | ||
| * <p>If the module expects its classloader to become collectible after detaching, it must also | ||
| * remove module-owned references and execution contexts that keep module objects reachable, such | ||
| * as installed hooks, Java threads, and callbacks held by system or app objects. If native code | ||
| * is still running after all Java references to the module classloader are cleared, later runtime | ||
| * unloading of native libraries may crash the process; this is a module lifecycle bug.</p> | ||
| * | ||
| * <p>Typical use cases include:</p> | ||
| * <ul> | ||
| * <li>The module entry has finished all its initialization work and no longer needs to | ||
| * respond to further package loading events.</li> | ||
| * <li>For modules that target multiple apps with a dedicated entry class per app: if the | ||
| * entry detects it is not loaded in its target app, it can call this method immediately to | ||
| * avoid receiving any further callbacks.</li> | ||
| * <li>Calling this method together with unhooking all registered hooks, so that the module | ||
| * classloader can be garbage collected when no longer needed.</li> | ||
| * </ul> | ||
| */ | ||
| @SinceApi(API_102) | ||
| @SuppressWarnings("unused") | ||
| public final void detach() { | ||
| ensureAttached(); | ||
| mDetachImpl.run(); | ||
| } | ||
| @Override | ||
| public final int getApiVersion() { | ||
| ensureAttached(); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.