[skip ci] Add note (#847)

* [skip ci] Add note

* add proper way
This commit is contained in:
vvb2060 2021-08-06 14:37:16 +08:00 committed by GitHub
parent c16176c637
commit 88e5869642
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 12 deletions

View File

@ -47,11 +47,7 @@ public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
String apk) {
super(dexBuffers, parent);
this.apk = apk;
try {
fixDexName(apk);
} catch (Throwable e) {
Utils.logE("fix name", e);
}
setDexName(apk);
}
@RequiresApi(Build.VERSION_CODES.Q)
@ -62,11 +58,7 @@ public final class LspModuleClassLoader extends ByteBufferDexClassLoader {
super(dexBuffers, librarySearchPath, parent);
initNativeLibraryDirs(librarySearchPath);
this.apk = apk;
try {
fixDexName(apk);
} catch (Throwable e) {
Utils.logE("fix name", e);
}
setDexName(apk);
}
private void initNativeLibraryDirs(String librarySearchPath) {

View File

@ -35,8 +35,15 @@ public class ByteBufferDexClassLoader extends BaseDexClassLoader {
super(dexFiles, librarySearchPath, parent);
}
public void fixDexName(String name) throws IllegalAccessException {
nameField.set(dexFileField.get(((Object[]) dexElementsField.get(pathListField.get(this)))[0]), name);
// Some modules get their module paths from this variable
// They should use `initZygote.modulePath` instead
// Temporarily workaround
// TODO(vvb2060): removed in the next major release
public void setDexName(String name){
try {
nameField.set(dexFileField.get(((Object[]) dexElementsField.get(pathListField.get(this)))[0]), name);
} catch (Throwable ignored) {
}
}
public String getLdLibraryPath() {