Skip to content

Commit

Permalink
Rename Apache class names to avoid conflicts
Browse files Browse the repository at this point in the history
We add a gradle task to rename class names in the Apache library
  • Loading branch information
JingMatrix committed Oct 31, 2024
1 parent f1f0b42 commit 8fb6afb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
apache/local/generated
.project
.settings
.cache
Expand Down
22 changes: 22 additions & 0 deletions apache/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,25 @@ java {
}
}
}

val lang3Src = "commons-lang/src/main/java/org/apache/commons/lang3"
val localDir = "local/generated"

task<Copy>("ClassUtilsX") {
from("$lang3Src/ClassUtils.java")
into(localDir)
filter { line: String -> line.replace("ClassUtils", "ClassUtilsX") }
rename("(.+).java", "$1X.java")
}

task<Copy>("SerializationUtilsX") {
from("$lang3Src/SerializationUtils.java")
into(localDir)
filter { line: String -> line.replace("SerializationUtils", "SerializationUtilsX") }
rename("(.+).java", "$1X.java")
}

tasks.compileJava {
dependsOn("ClassUtilsX")
dependsOn("SerializationUtilsX")
}
File renamed without changes.
8 changes: 4 additions & 4 deletions core/src/main/java/de/robv/android/xposed/XposedHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.ClassUtilsX;
import org.apache.commons.lang3.reflect.MemberUtilsX;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -202,7 +202,7 @@ public static Class<?> findClass(String className, ClassLoader classLoader) {
if (classLoader == null)
classLoader = XposedBridge.BOOTCLASSLOADER;
try {
return ClassUtils.getClass(classLoader, className, false);
return ClassUtilsX.getClass(classLoader, className, false);
} catch (ClassNotFoundException e) {
throw new ClassNotFoundError(e);
}
Expand Down Expand Up @@ -540,7 +540,7 @@ public static Method findMethodBestMatch(Class<?> clazz, String methodName, Clas
continue;

// compare name and parameters
if (method.getName().equals(k.name) && ClassUtils.isAssignable(
if (method.getName().equals(k.name) && ClassUtilsX.isAssignable(
k.parameters,
method.getParameterTypes(),
true)) {
Expand Down Expand Up @@ -763,7 +763,7 @@ public static Constructor<?> findConstructorBestMatch(Class<?> clazz, Class<?>..
Constructor<?>[] constructors = k.clazz.getDeclaredConstructors();
for (Constructor<?> constructor : constructors) {
// compare name and parameters
if (ClassUtils.isAssignable(
if (ClassUtilsX.isAssignable(
k.parameters,
constructor.getParameterTypes(),
true)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.apache.commons.lang3.SerializationUtils;
import org.apache.commons.lang3.SerializationUtilsX;
import org.lsposed.daemon.BuildConfig;
import org.lsposed.lspd.models.Application;
import org.lsposed.lspd.models.Module;
Expand Down Expand Up @@ -464,7 +464,7 @@ Map<String, HashMap<String, Object>> fetchModuleConfig(String name, int user_id)
var group = cursor.getString(groupIdx);
var key = cursor.getString(keyIdx);
var data = cursor.getBlob(dataIdx);
var object = SerializationUtils.deserialize(data);
var object = SerializationUtilsX.deserialize(data);
if (object == null) continue;
config.computeIfAbsent(group, g -> new HashMap<>()).put(key, object);
}
Expand All @@ -491,7 +491,7 @@ public void updateModulePrefs(String moduleName, int userId, String group, Map<S
var contents = new ContentValues();
contents.put("`group`", group);
contents.put("`key`", key);
contents.put("data", SerializationUtils.serialize((Serializable) value));
contents.put("data", SerializationUtilsX.serialize((Serializable) value));
contents.put("module_pkg_name", moduleName);
contents.put("user_id", String.valueOf(userId));
db.insertWithOnConflict("configs", null, contents, SQLiteDatabase.CONFLICT_REPLACE);
Expand Down

0 comments on commit 8fb6afb

Please sign in to comment.