|
|
@ -19,7 +19,8 @@ |
|
|
|
|
|
|
|
|
|
|
|
package jode.jvm; |
|
|
|
package jode.jvm; |
|
|
|
import jode.GlobalOptions; |
|
|
|
import jode.GlobalOptions; |
|
|
|
import jode.bytecode.BytecodeInfo; |
|
|
|
import jode.bytecode.BasicBlocks; |
|
|
|
|
|
|
|
import jode.bytecode.Block; |
|
|
|
import jode.bytecode.ClassInfo; |
|
|
|
import jode.bytecode.ClassInfo; |
|
|
|
import jode.bytecode.FieldInfo; |
|
|
|
import jode.bytecode.FieldInfo; |
|
|
|
import jode.bytecode.Handler; |
|
|
|
import jode.bytecode.Handler; |
|
|
@ -32,7 +33,9 @@ import jode.type.MethodType; |
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Modifier; |
|
|
|
import java.lang.reflect.Modifier; |
|
|
|
|
|
|
|
|
|
|
|
import @COLLECTIONS@.Iterator; |
|
|
|
///#def COLLECTIONS java.util
|
|
|
|
|
|
|
|
import java.util.Iterator; |
|
|
|
|
|
|
|
///#enddef
|
|
|
|
|
|
|
|
|
|
|
|
public class SyntheticAnalyzer implements Opcodes { |
|
|
|
public class SyntheticAnalyzer implements Opcodes { |
|
|
|
public final static int UNKNOWN = 0; |
|
|
|
public final static int UNKNOWN = 0; |
|
|
@ -47,11 +50,14 @@ public class SyntheticAnalyzer implements Opcodes { |
|
|
|
|
|
|
|
|
|
|
|
int kind = UNKNOWN; |
|
|
|
int kind = UNKNOWN; |
|
|
|
Reference reference; |
|
|
|
Reference reference; |
|
|
|
|
|
|
|
ClassInfo classInfo; |
|
|
|
MethodInfo method; |
|
|
|
MethodInfo method; |
|
|
|
|
|
|
|
|
|
|
|
public SyntheticAnalyzer(MethodInfo method, boolean checkName) { |
|
|
|
public SyntheticAnalyzer(ClassInfo classInfo, MethodInfo method, |
|
|
|
|
|
|
|
boolean checkName) { |
|
|
|
|
|
|
|
this.classInfo = classInfo; |
|
|
|
this.method = method; |
|
|
|
this.method = method; |
|
|
|
if (method.getBytecode() == null) |
|
|
|
if (method.getBasicBlocks() == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
if (!checkName || method.getName().equals("class$")) |
|
|
|
if (!checkName || method.getName().equals("class$")) |
|
|
|
if (checkGetClass()) |
|
|
|
if (checkGetClass()) |
|
|
@ -94,37 +100,50 @@ public class SyntheticAnalyzer implements Opcodes { |
|
|
|
.equals("(Ljava/lang/String;)Ljava/lang/Class;"))) |
|
|
|
.equals("(Ljava/lang/String;)Ljava/lang/Class;"))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
BytecodeInfo bytecode = method.getBytecode(); |
|
|
|
BasicBlocks bb = method.getBasicBlocks(); |
|
|
|
|
|
|
|
|
|
|
|
Handler[] excHandlers = bytecode.getExceptionHandlers(); |
|
|
|
Block[] blocks = bb.getBlocks(); |
|
|
|
if (excHandlers.length != 1 |
|
|
|
Block startBlock = bb.getStartBlock(); |
|
|
|
|| !"java.lang.ClassNotFoundException".equals(excHandlers[0].type)) |
|
|
|
Handler[] excHandlers = bb.getExceptionHandlers(); |
|
|
|
|
|
|
|
if (startBlock == null |
|
|
|
|
|
|
|
|| startBlock.getInstructions().size() != 3 |
|
|
|
|
|
|
|
|| excHandlers.length != 1 |
|
|
|
|
|
|
|
|| excHandlers[0].getStart() != startBlock |
|
|
|
|
|
|
|
|| excHandlers[0].getEnd() != startBlock |
|
|
|
|
|
|
|
|| !"java.lang.ClassNotFoundException" |
|
|
|
|
|
|
|
.equals(excHandlers[0].getType())) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
int excSlot = -1; |
|
|
|
for (int i=0; i< 3; i++) { |
|
|
|
int i = 0; |
|
|
|
Instruction instr = |
|
|
|
for (Iterator iter = bytecode.getInstructions().iterator(); iter.hasNext(); i++) { |
|
|
|
(Instruction) startBlock.getInstructions().get(i); |
|
|
|
Instruction instr = (Instruction) iter.next(); |
|
|
|
if (instr.getOpcode() != getClassOpcodes[i]) |
|
|
|
if (i == getClassOpcodes.length |
|
|
|
|
|
|
|
|| instr.getOpcode() != getClassOpcodes[i]) |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (i == 0 && (instr.getLocalSlot() != 0 |
|
|
|
if (getClassRefs[i] != null |
|
|
|
|| excHandlers[0].start != instr)) |
|
|
|
&& !getClassRefs[i].equals(instr.getReference())) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
if (i == 0 && instr.getLocalSlot() != 0) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Block catchBlock = excHandlers[0].getCatcher(); |
|
|
|
|
|
|
|
if (catchBlock.getInstructions().size() != 7) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (i == 2 && excHandlers[0].end != instr) |
|
|
|
int excSlot = -1; |
|
|
|
|
|
|
|
for (int i=0; i< 7; i++) { |
|
|
|
|
|
|
|
Instruction instr = (Instruction) |
|
|
|
|
|
|
|
catchBlock.getInstructions().get(i); |
|
|
|
|
|
|
|
if (instr.getOpcode() != getClassOpcodes[3+i]) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (i == 3) { |
|
|
|
if (getClassRefs[3+i] != null |
|
|
|
if (excHandlers[0].catcher != instr) |
|
|
|
&& !getClassRefs[3+i].equals(instr.getReference())) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
if (i == 0) |
|
|
|
excSlot = instr.getLocalSlot(); |
|
|
|
excSlot = instr.getLocalSlot(); |
|
|
|
} |
|
|
|
if (i == 1 && !instr.getClazzType().equals |
|
|
|
if (i == 4 && !instr.getClazzType().equals |
|
|
|
|
|
|
|
("Ljava/lang/NoClassDefFoundError;")) |
|
|
|
("Ljava/lang/NoClassDefFoundError;")) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (i == 6 && instr.getLocalSlot() != excSlot) |
|
|
|
if (i == 3 && instr.getLocalSlot() != excSlot) |
|
|
|
return false; |
|
|
|
|
|
|
|
if (getClassRefs[i] != null |
|
|
|
|
|
|
|
&& !getClassRefs[i].equals(instr.getReference())) |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
this.kind = GETCLASS; |
|
|
|
this.kind = GETCLASS; |
|
|
@ -135,22 +154,35 @@ public class SyntheticAnalyzer implements Opcodes { |
|
|
|
Modifier.PUBLIC | Modifier.STATIC); |
|
|
|
Modifier.PUBLIC | Modifier.STATIC); |
|
|
|
|
|
|
|
|
|
|
|
public boolean checkStaticAccess() { |
|
|
|
public boolean checkStaticAccess() { |
|
|
|
ClassInfo clazzInfo = method.getClazzInfo(); |
|
|
|
BasicBlocks bb = method.getBasicBlocks(); |
|
|
|
BytecodeInfo bytecode = method.getBytecode(); |
|
|
|
Handler[] excHandlers = bb.getExceptionHandlers(); |
|
|
|
Iterator iter = bytecode.getInstructions().iterator(); |
|
|
|
if (excHandlers != null && excHandlers.length != 0) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
Block[] blocks = bb.getBlocks(); |
|
|
|
|
|
|
|
Block startBlock = bb.getStartBlock(); |
|
|
|
|
|
|
|
if (startBlock == null) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
Block[] succBlocks = startBlock.getSuccs(); |
|
|
|
|
|
|
|
if (succBlocks.length > 1 || |
|
|
|
|
|
|
|
(succBlocks.length == 1 && succBlocks[0] != null)) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
Iterator iter = startBlock.getInstructions().iterator(); |
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
Instruction instr = (Instruction) iter.next(); |
|
|
|
Instruction instr = (Instruction) iter.next(); |
|
|
|
if (instr.getOpcode() == opc_getstatic) { |
|
|
|
if (instr.getOpcode() == opc_getstatic) { |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
.equals(clazzInfo.getName().replace('.','/')))) |
|
|
|
.equals(classInfo.getName().replace('.','/')))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
FieldInfo refField |
|
|
|
FieldInfo refField |
|
|
|
= clazzInfo.findField(ref.getName(), ref.getType()); |
|
|
|
= classInfo.findField(ref.getName(), ref.getType()); |
|
|
|
if ((refField.getModifiers() & modifierMask) != |
|
|
|
if ((refField.getModifiers() & modifierMask) != |
|
|
|
(Modifier.PRIVATE | Modifier.STATIC)) |
|
|
|
(Modifier.PRIVATE | Modifier.STATIC)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
if (instr.getOpcode() < opc_ireturn |
|
|
|
if (instr.getOpcode() < opc_ireturn |
|
|
|
|| instr.getOpcode() > opc_areturn) |
|
|
|
|| instr.getOpcode() > opc_areturn) |
|
|
@ -167,6 +199,8 @@ public class SyntheticAnalyzer implements Opcodes { |
|
|
|
params++; |
|
|
|
params++; |
|
|
|
slot += (instr.getOpcode() == opc_lload |
|
|
|
slot += (instr.getOpcode() == opc_lload |
|
|
|
|| instr.getOpcode() == opc_dload) ? 2 : 1; |
|
|
|
|| instr.getOpcode() == opc_dload) ? 2 : 1; |
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (instr.getOpcode() == opc_putstatic) { |
|
|
|
if (instr.getOpcode() == opc_putstatic) { |
|
|
@ -176,13 +210,15 @@ public class SyntheticAnalyzer implements Opcodes { |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
.equals(clazzInfo.getName().replace('.','/')))) |
|
|
|
.equals(classInfo.getName().replace('.','/')))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
FieldInfo refField |
|
|
|
FieldInfo refField |
|
|
|
= clazzInfo.findField(ref.getName(), ref.getType()); |
|
|
|
= classInfo.findField(ref.getName(), ref.getType()); |
|
|
|
if ((refField.getModifiers() & modifierMask) != |
|
|
|
if ((refField.getModifiers() & modifierMask) != |
|
|
|
(Modifier.PRIVATE | Modifier.STATIC)) |
|
|
|
(Modifier.PRIVATE | Modifier.STATIC)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
if (instr.getOpcode() != opc_return) |
|
|
|
if (instr.getOpcode() != opc_return) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -194,20 +230,25 @@ public class SyntheticAnalyzer implements Opcodes { |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
.equals(clazzInfo.getName().replace('.','/')))) |
|
|
|
.equals(classInfo.getName().replace('.','/')))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
MethodInfo refMethod |
|
|
|
MethodInfo refMethod |
|
|
|
= clazzInfo.findMethod(ref.getName(), ref.getType()); |
|
|
|
= classInfo.findMethod(ref.getName(), ref.getType()); |
|
|
|
MethodType refType = Type.tMethod(ref.getType()); |
|
|
|
MethodType refType = Type.tMethod(ref.getType()); |
|
|
|
if ((refMethod.getModifiers() & modifierMask) != |
|
|
|
if ((refMethod.getModifiers() & modifierMask) != |
|
|
|
(Modifier.PRIVATE | Modifier.STATIC) |
|
|
|
(Modifier.PRIVATE | Modifier.STATIC) |
|
|
|
|| refType.getParameterTypes().length != params) |
|
|
|
|| refType.getParameterTypes().length != params) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
if (refType.getReturnType() == Type.tVoid) { |
|
|
|
if (refType.getReturnType() == Type.tVoid) { |
|
|
|
if (instr.getOpcode() != opc_return) |
|
|
|
if (iter.hasNext()) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
if (instr.getOpcode() < opc_ireturn |
|
|
|
if (instr.getOpcode() < opc_ireturn |
|
|
|
|| instr.getOpcode() > opc_areturn) |
|
|
|
|| instr.getOpcode() > opc_areturn) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -222,33 +263,46 @@ public class SyntheticAnalyzer implements Opcodes { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean checkAccess() { |
|
|
|
public boolean checkAccess() { |
|
|
|
ClassInfo clazzInfo = method.getClazzInfo(); |
|
|
|
|
|
|
|
BytecodeInfo bytecode = method.getBytecode(); |
|
|
|
|
|
|
|
Handler[] excHandlers = bytecode.getExceptionHandlers(); |
|
|
|
|
|
|
|
if (excHandlers != null && excHandlers.length != 0) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (method.isStatic()) { |
|
|
|
if (method.isStatic()) { |
|
|
|
if (checkStaticAccess()) |
|
|
|
if (checkStaticAccess()) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Iterator iter = bytecode.getInstructions().iterator(); |
|
|
|
BasicBlocks bb = method.getBasicBlocks(); |
|
|
|
|
|
|
|
Handler[] excHandlers = bb.getExceptionHandlers(); |
|
|
|
|
|
|
|
if (excHandlers != null && excHandlers.length != 0) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
Block[] blocks = bb.getBlocks(); |
|
|
|
|
|
|
|
Block startBlock = bb.getStartBlock(); |
|
|
|
|
|
|
|
if (startBlock == null) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
Block[] succBlocks = startBlock.getSuccs(); |
|
|
|
|
|
|
|
if (succBlocks.length > 1 || |
|
|
|
|
|
|
|
(succBlocks.length == 1 && succBlocks[0] != null)) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
Iterator iter = startBlock.getInstructions().iterator(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
Instruction instr = (Instruction) iter.next(); |
|
|
|
Instruction instr = (Instruction) iter.next(); |
|
|
|
if (instr.getOpcode() != opc_aload || instr.getLocalSlot() != 0) |
|
|
|
if (instr.getOpcode() != opc_aload || instr.getLocalSlot() != 0) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
|
|
|
|
|
|
|
|
if (instr.getOpcode() == opc_getfield) { |
|
|
|
if (instr.getOpcode() == opc_getfield) { |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
.equals(clazzInfo.getName().replace('.','/')))) |
|
|
|
.equals(classInfo.getName().replace('.','/')))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
FieldInfo refField |
|
|
|
FieldInfo refField |
|
|
|
= clazzInfo.findField(ref.getName(), ref.getType()); |
|
|
|
= classInfo.findField(ref.getName(), ref.getType()); |
|
|
|
if ((refField.getModifiers() & modifierMask) != Modifier.PRIVATE) |
|
|
|
if ((refField.getModifiers() & modifierMask) != Modifier.PRIVATE) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
if (instr.getOpcode() < opc_ireturn |
|
|
|
if (instr.getOpcode() < opc_ireturn |
|
|
|
|| instr.getOpcode() > opc_areturn) |
|
|
|
|| instr.getOpcode() > opc_areturn) |
|
|
@ -265,6 +319,8 @@ public class SyntheticAnalyzer implements Opcodes { |
|
|
|
params++; |
|
|
|
params++; |
|
|
|
slot += (instr.getOpcode() == opc_lload |
|
|
|
slot += (instr.getOpcode() == opc_lload |
|
|
|
|| instr.getOpcode() == opc_dload) ? 2 : 1; |
|
|
|
|| instr.getOpcode() == opc_dload) ? 2 : 1; |
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (instr.getOpcode() == opc_putfield) { |
|
|
|
if (instr.getOpcode() == opc_putfield) { |
|
|
@ -274,14 +330,13 @@ public class SyntheticAnalyzer implements Opcodes { |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
.equals(clazzInfo.getName().replace('.','/')))) |
|
|
|
.equals(classInfo.getName().replace('.','/')))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
FieldInfo refField |
|
|
|
FieldInfo refField |
|
|
|
= clazzInfo.findField(ref.getName(), ref.getType()); |
|
|
|
= classInfo.findField(ref.getName(), ref.getType()); |
|
|
|
if ((refField.getModifiers() & modifierMask) != Modifier.PRIVATE) |
|
|
|
if ((refField.getModifiers() & modifierMask) != Modifier.PRIVATE) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
if (iter.hasNext()) |
|
|
|
if (instr.getOpcode() != opc_return) |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
reference = ref; |
|
|
|
reference = ref; |
|
|
|
kind = ACCESSPUTFIELD; |
|
|
|
kind = ACCESSPUTFIELD; |
|
|
@ -291,19 +346,21 @@ public class SyntheticAnalyzer implements Opcodes { |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
.equals(clazzInfo.getName().replace('.','/')))) |
|
|
|
.equals(classInfo.getName().replace('.','/')))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
MethodInfo refMethod |
|
|
|
MethodInfo refMethod |
|
|
|
= clazzInfo.findMethod(ref.getName(), ref.getType()); |
|
|
|
= classInfo.findMethod(ref.getName(), ref.getType()); |
|
|
|
MethodType refType = Type.tMethod(ref.getType()); |
|
|
|
MethodType refType = Type.tMethod(ref.getType()); |
|
|
|
if ((refMethod.getModifiers() & modifierMask) != Modifier.PRIVATE |
|
|
|
if ((refMethod.getModifiers() & modifierMask) != Modifier.PRIVATE |
|
|
|
|| refType.getParameterTypes().length != params) |
|
|
|
|| refType.getParameterTypes().length != params) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
|
|
|
|
if (refType.getReturnType() == Type.tVoid) { |
|
|
|
if (refType.getReturnType() == Type.tVoid) { |
|
|
|
if (instr.getOpcode() != opc_return) |
|
|
|
if (iter.hasNext()) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
if (instr.getOpcode() < opc_ireturn |
|
|
|
if (instr.getOpcode() < opc_ireturn |
|
|
|
|| instr.getOpcode() > opc_areturn) |
|
|
|
|| instr.getOpcode() > opc_areturn) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -318,16 +375,25 @@ public class SyntheticAnalyzer implements Opcodes { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean checkConstructorAccess() { |
|
|
|
public boolean checkConstructorAccess() { |
|
|
|
ClassInfo clazzInfo = method.getClazzInfo(); |
|
|
|
BasicBlocks bb = method.getBasicBlocks(); |
|
|
|
BytecodeInfo bytecode = method.getBytecode(); |
|
|
|
Handler[] excHandlers = bb.getExceptionHandlers(); |
|
|
|
Handler[] excHandlers = bytecode.getExceptionHandlers(); |
|
|
|
|
|
|
|
if (excHandlers != null && excHandlers.length != 0) |
|
|
|
if (excHandlers != null && excHandlers.length != 0) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
Block[] blocks = bb.getBlocks(); |
|
|
|
Iterator iter = bytecode.getInstructions().iterator(); |
|
|
|
Block startBlock = bb.getStartBlock(); |
|
|
|
|
|
|
|
if (startBlock == null) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
Block[] succBlocks = startBlock.getSuccs(); |
|
|
|
|
|
|
|
if (succBlocks.length != 1 || succBlocks[0] != null) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
Iterator iter = startBlock.getInstructions().iterator(); |
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
Instruction instr = (Instruction) iter.next(); |
|
|
|
Instruction instr = (Instruction) iter.next(); |
|
|
|
if (instr.getOpcode() != opc_aload || instr.getLocalSlot() != 0) |
|
|
|
if (instr.getOpcode() != opc_aload || instr.getLocalSlot() != 0) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
|
|
|
|
|
|
|
|
// slot begins with 2. Slot 1 contains a dummy value, that
|
|
|
|
// slot begins with 2. Slot 1 contains a dummy value, that
|
|
|
@ -339,25 +405,25 @@ public class SyntheticAnalyzer implements Opcodes { |
|
|
|
params++; |
|
|
|
params++; |
|
|
|
slot += (instr.getOpcode() == opc_lload |
|
|
|
slot += (instr.getOpcode() == opc_lload |
|
|
|
|| instr.getOpcode() == opc_dload) ? 2 : 1; |
|
|
|
|| instr.getOpcode() == opc_dload) ? 2 : 1; |
|
|
|
|
|
|
|
if (!iter.hasNext()) |
|
|
|
|
|
|
|
return false; |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (instr.getOpcode() == opc_invokespecial) { |
|
|
|
if (instr.getOpcode() == opc_invokespecial) { |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
Reference ref = instr.getReference(); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
String refClazz = ref.getClazz().substring(1); |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
if (!(refClazz.substring(0, refClazz.length()-1) |
|
|
|
.equals(clazzInfo.getName().replace('.','/')))) |
|
|
|
.equals(classInfo.getName().replace('.','/')))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
MethodInfo refMethod |
|
|
|
MethodInfo refMethod |
|
|
|
= clazzInfo.findMethod(ref.getName(), ref.getType()); |
|
|
|
= classInfo.findMethod(ref.getName(), ref.getType()); |
|
|
|
MethodType refType = Type.tMethod(ref.getType()); |
|
|
|
MethodType refType = Type.tMethod(ref.getType()); |
|
|
|
if ((refMethod.getModifiers() & modifierMask) != Modifier.PRIVATE |
|
|
|
if ((refMethod.getModifiers() & modifierMask) != Modifier.PRIVATE |
|
|
|
|| !refMethod.getName().equals("<init>") |
|
|
|
|| !refMethod.getName().equals("<init>") |
|
|
|
|| refType.getParameterTypes().length != params) |
|
|
|
|| refType.getParameterTypes().length != params) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
instr = (Instruction) iter.next(); |
|
|
|
if (iter.hasNext()) |
|
|
|
if (instr.getOpcode() != opc_return) |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
/* For valid bytecode the types matches automatically */ |
|
|
|
/* For valid bytecode the types matches automatically */ |
|
|
|
reference = ref; |
|
|
|
reference = ref; |
|
|
|
kind = ACCESSCONSTRUCTOR; |
|
|
|
kind = ACCESSCONSTRUCTOR; |