use*_*017 2 java java-bytecode-asm
实际我在类中有一个方法如下.
public static final void print(String str){
System.out.println(str);
}
Run Code Online (Sandbox Code Playgroud)
我想final从met hod中删除修饰符.所以在这之后,我的方法将如下所示:
public static void print(String str){
System.out.println(str);
}
Run Code Online (Sandbox Code Playgroud)
使用ASM,我们将获得此信息
public MethodVisitor visitMethod(int access, String name,
String desc, String signature,
String[] exceptions) { }
Run Code Online (Sandbox Code Playgroud)
在上面,我认为要实现上述情况,我们需要使用access参数.但访问是公共+静态+最终的总和.如何删除最终是我的问题?
类级最终修饰符也一样吗?
你只需要像这样清除"最终"位:
public MethodVisitor visitMethod(int access, String name,
String desc, String signature,
String[] exceptions) {
return super.visitMethod(
access & (~Opcodes.ACC_FINAL),
name, desc, signature, exceptions);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1221 次 |
| 最近记录: |