Skip to content
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

升级javassist到3.22.0-GA版本,过滤module-info.class,解决 java.io.IOException: invalid constant type: 19 at 5 #431

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ dependencies {
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.android.support:design:25.4.0'
compile 'org.javassist:javassist:3.20.0-GA'
compile 'org.javassist:javassist:3.22.0-GA'
compile project(path: ':patch')
}
2 changes: 1 addition & 1 deletion auto-patch-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies {
compile gradleApi()
compile localGroovy()
compile 'com.android.tools.build:gradle:2.1.0'
compile 'org.javassist:javassist:3.20.0-GA'
compile 'org.javassist:javassist:3.22.0-GA'
// compile 'com.meituan.robust:autopatchbase:' + VERSION_NAME
compile project(':autopatchbase')
}
Expand Down
2 changes: 1 addition & 1 deletion gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies {
compile gradleApi()
compile localGroovy()
compile 'com.android.tools.build:gradle:2.1.0'
compile 'org.javassist:javassist:3.20.0-GA'
compile 'org.javassist:javassist:3.22.0-GA'
compile fileTree(dir: "./src/main/libs", include: ['*.jar'])
compile project(':autopatchbase')
// compile 'com.meituan.robust:autopatchbase:0.4.93'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ protected void insertCode(List<CtClass> box, File jarFile) throws IOException, C
ZipOutputStream outStream = new JarOutputStream(new FileOutputStream(jarFile));
//get every class in the box ,ready to insert code
for (CtClass ctClass : box) {
/**
* 过滤掉javassis 从3.20.0-GA升级到3.22.0-GA产生的module-info.class
* 因为3.22.0-GA是使用java9编译的,会产生一个叫module-info.class的文件类
*/
if ("META-INF.versions.9.module-info".equals(ctClass.getName())) {
continue;
}
//change modifier to public ,so all the class in the apk will be public ,you will be able to access it in the patch
ctClass.setModifiers(AccessFlag.setPublic(ctClass.getModifiers()));
if (isNeedInsertClass(ctClass.getName()) && !(ctClass.isInterface() || ctClass.getDeclaredMethods().length < 1)) {
Expand Down