|
|
@ -62,6 +62,7 @@ public final class InvokeOperator extends Operator |
|
|
|
int methodFlag; |
|
|
|
int methodFlag; |
|
|
|
MethodType methodType; |
|
|
|
MethodType methodType; |
|
|
|
String methodName; |
|
|
|
String methodName; |
|
|
|
|
|
|
|
Reference ref; |
|
|
|
int skippedArgs; |
|
|
|
int skippedArgs; |
|
|
|
ClassType classType; |
|
|
|
ClassType classType; |
|
|
|
Type[] hints; |
|
|
|
Type[] hints; |
|
|
@ -149,6 +150,7 @@ public final class InvokeOperator extends Operator |
|
|
|
int methodFlag, Reference reference) { |
|
|
|
int methodFlag, Reference reference) { |
|
|
|
super(Type.tUnknown, 0); |
|
|
|
super(Type.tUnknown, 0); |
|
|
|
this.classPath = methodAnalyzer.getClassAnalyzer().getClassPath(); |
|
|
|
this.classPath = methodAnalyzer.getClassAnalyzer().getClassPath(); |
|
|
|
|
|
|
|
this.ref = reference; |
|
|
|
this.methodType = Type.tMethod(classPath, reference.getType()); |
|
|
|
this.methodType = Type.tMethod(classPath, reference.getType()); |
|
|
|
this.methodName = reference.getName(); |
|
|
|
this.methodName = reference.getName(); |
|
|
|
this.classType = (ClassType) |
|
|
|
this.classType = (ClassType) |
|
|
@ -208,6 +210,26 @@ public final class InvokeOperator extends Operator |
|
|
|
return methodName; |
|
|
|
return methodName; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static MethodInfo getMethodInfo(ClassInfo clazz, |
|
|
|
|
|
|
|
String name, String type) { |
|
|
|
|
|
|
|
while (clazz != null) { |
|
|
|
|
|
|
|
MethodInfo method = clazz.findMethod(name, type); |
|
|
|
|
|
|
|
if (method != null) |
|
|
|
|
|
|
|
return method; |
|
|
|
|
|
|
|
clazz = clazz.getSuperclass(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MethodInfo getMethodInfo() { |
|
|
|
|
|
|
|
ClassInfo clazz; |
|
|
|
|
|
|
|
if (ref.getClazz().charAt(0) == '[') |
|
|
|
|
|
|
|
clazz = classPath.getClassInfo("java.lang.Object"); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
clazz = TypeSignature.getClassInfo(classPath, ref.getClazz()); |
|
|
|
|
|
|
|
return getMethodInfo(clazz, ref.getName(), ref.getType()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Type getClassType() { |
|
|
|
public Type getClassType() { |
|
|
|
return classType; |
|
|
|
return classType; |
|
|
|
} |
|
|
|
} |
|
|
@ -603,14 +625,20 @@ public final class InvokeOperator extends Operator |
|
|
|
synth.getReference()); |
|
|
|
synth.getReference()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case SyntheticAnalyzer.ACCESSPUTFIELD: |
|
|
|
case SyntheticAnalyzer.ACCESSPUTFIELD: |
|
|
|
|
|
|
|
case SyntheticAnalyzer.ACCESSDUPPUTFIELD: |
|
|
|
op = new StoreInstruction |
|
|
|
op = new StoreInstruction |
|
|
|
(new PutFieldOperator(methodAnalyzer, false, |
|
|
|
(new PutFieldOperator(methodAnalyzer, false, |
|
|
|
synth.getReference())); |
|
|
|
synth.getReference())); |
|
|
|
|
|
|
|
if (synth.getKind() == synth.ACCESSDUPPUTFIELD) |
|
|
|
|
|
|
|
((StoreInstruction) op).makeNonVoid(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case SyntheticAnalyzer.ACCESSPUTSTATIC: |
|
|
|
case SyntheticAnalyzer.ACCESSPUTSTATIC: |
|
|
|
|
|
|
|
case SyntheticAnalyzer.ACCESSDUPPUTSTATIC: |
|
|
|
op = new StoreInstruction |
|
|
|
op = new StoreInstruction |
|
|
|
(new PutFieldOperator(methodAnalyzer, true, |
|
|
|
(new PutFieldOperator(methodAnalyzer, true, |
|
|
|
synth.getReference())); |
|
|
|
synth.getReference())); |
|
|
|
|
|
|
|
if (synth.getKind() == synth.ACCESSDUPPUTSTATIC) |
|
|
|
|
|
|
|
((StoreInstruction) op).makeNonVoid(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case SyntheticAnalyzer.ACCESSMETHOD: |
|
|
|
case SyntheticAnalyzer.ACCESSMETHOD: |
|
|
|
op = new InvokeOperator(methodAnalyzer, ACCESSSPECIAL, |
|
|
|
op = new InvokeOperator(methodAnalyzer, ACCESSSPECIAL, |
|
|
@ -669,9 +697,35 @@ public final class InvokeOperator extends Operator |
|
|
|
Type realClassType; |
|
|
|
Type realClassType; |
|
|
|
if (methodFlag == STATIC) |
|
|
|
if (methodFlag == STATIC) |
|
|
|
realClassType = classType; |
|
|
|
realClassType = classType; |
|
|
|
else { |
|
|
|
else if (param == 0) { |
|
|
|
if (param == 0) |
|
|
|
if (paramTypes[0] instanceof NullType) |
|
|
|
return paramTypes[0] instanceof NullType; |
|
|
|
return true; |
|
|
|
|
|
|
|
if (!(paramTypes[0] instanceof ClassInfoType |
|
|
|
|
|
|
|
&& classType instanceof ClassInfoType)) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ClassInfo clazz = ((ClassInfoType) classType).getClassInfo(); |
|
|
|
|
|
|
|
ClassInfo parClazz |
|
|
|
|
|
|
|
= ((ClassInfoType) paramTypes[0]).getClassInfo(); |
|
|
|
|
|
|
|
MethodInfo method = getMethodInfo(); |
|
|
|
|
|
|
|
if (method == null) |
|
|
|
|
|
|
|
/* This is a NoSuchMethodError */ |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
if (Modifier.isPrivate(method.getModifiers())) |
|
|
|
|
|
|
|
return parClazz != clazz; |
|
|
|
|
|
|
|
else if ((method.getModifiers() |
|
|
|
|
|
|
|
& (Modifier.PROTECTED | Modifier.PUBLIC)) == 0) { |
|
|
|
|
|
|
|
/* Method is protected. We need a cast if parClazz is in |
|
|
|
|
|
|
|
* other package than clazz. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
int lastDot = clazz.getName().lastIndexOf('.'); |
|
|
|
|
|
|
|
if (lastDot != parClazz.getName().lastIndexOf('.') |
|
|
|
|
|
|
|
|| !(parClazz.getName() |
|
|
|
|
|
|
|
.startsWith(clazz.getName().substring(0,lastDot+1)))) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} else { |
|
|
|
realClassType = paramTypes[0]; |
|
|
|
realClassType = paramTypes[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -765,6 +819,7 @@ public final class InvokeOperator extends Operator |
|
|
|
int arg = 1; |
|
|
|
int arg = 1; |
|
|
|
int length = subExpressions.length; |
|
|
|
int length = subExpressions.length; |
|
|
|
boolean jikesAnonymousInner = false; |
|
|
|
boolean jikesAnonymousInner = false; |
|
|
|
|
|
|
|
boolean implicitOuterClass = false; |
|
|
|
|
|
|
|
|
|
|
|
if ((Options.options & Options.OPTION_ANON) != 0 |
|
|
|
if ((Options.options & Options.OPTION_ANON) != 0 |
|
|
|
&& clazzAna != null && clazz.isMethodScoped()) { |
|
|
|
&& clazzAna != null && clazz.isMethodScoped()) { |
|
|
@ -772,6 +827,7 @@ public final class InvokeOperator extends Operator |
|
|
|
OuterValues ov = clazzAna.getOuterValues(); |
|
|
|
OuterValues ov = clazzAna.getOuterValues(); |
|
|
|
arg += ov.getCount(); |
|
|
|
arg += ov.getCount(); |
|
|
|
jikesAnonymousInner = ov.isJikesAnonymousInner(); |
|
|
|
jikesAnonymousInner = ov.isJikesAnonymousInner(); |
|
|
|
|
|
|
|
implicitOuterClass = ov.isImplicitOuterClass(); |
|
|
|
|
|
|
|
|
|
|
|
for (int i=1; i< arg; i++) { |
|
|
|
for (int i=1; i< arg; i++) { |
|
|
|
Expression expr = subExpressions[i]; |
|
|
|
Expression expr = subExpressions[i]; |
|
|
@ -799,7 +855,9 @@ public final class InvokeOperator extends Operator |
|
|
|
if ((~Options.options & (Options.OPTION_INNER |
|
|
|
if ((~Options.options & (Options.OPTION_INNER |
|
|
|
| Options.OPTION_CONTRAFO)) == 0 |
|
|
|
| Options.OPTION_CONTRAFO)) == 0 |
|
|
|
&& clazz.getOuterClass() != null |
|
|
|
&& clazz.getOuterClass() != null |
|
|
|
&& !Modifier.isStatic(clazz.getModifiers())) { |
|
|
|
&& !Modifier.isStatic(clazz.getModifiers()) |
|
|
|
|
|
|
|
&& !implicitOuterClass |
|
|
|
|
|
|
|
&& arg < length) { |
|
|
|
|
|
|
|
|
|
|
|
Expression outerExpr = jikesAnonymousInner |
|
|
|
Expression outerExpr = jikesAnonymousInner |
|
|
|
? subExpressions[--length] |
|
|
|
? subExpressions[--length] |
|
|
@ -883,6 +941,7 @@ public final class InvokeOperator extends Operator |
|
|
|
|
|
|
|
|
|
|
|
boolean qualifiedNew = false; |
|
|
|
boolean qualifiedNew = false; |
|
|
|
boolean jikesAnonymousInner = false; |
|
|
|
boolean jikesAnonymousInner = false; |
|
|
|
|
|
|
|
boolean implicitOuterClass = false; |
|
|
|
|
|
|
|
|
|
|
|
/* clazz != null, since an array doesn't have a constructor */ |
|
|
|
/* clazz != null, since an array doesn't have a constructor */ |
|
|
|
|
|
|
|
|
|
|
@ -894,6 +953,7 @@ public final class InvokeOperator extends Operator |
|
|
|
OuterValues ov = clazzAna.getOuterValues(); |
|
|
|
OuterValues ov = clazzAna.getOuterValues(); |
|
|
|
arg += ov.getCount(); |
|
|
|
arg += ov.getCount(); |
|
|
|
jikesAnonymousInner = ov.isJikesAnonymousInner(); |
|
|
|
jikesAnonymousInner = ov.isJikesAnonymousInner(); |
|
|
|
|
|
|
|
implicitOuterClass = ov.isImplicitOuterClass(); |
|
|
|
|
|
|
|
|
|
|
|
if (clazz.getClassName() == null) { |
|
|
|
if (clazz.getClassName() == null) { |
|
|
|
/* This is an anonymous class */ |
|
|
|
/* This is an anonymous class */ |
|
|
@ -933,17 +993,22 @@ public final class InvokeOperator extends Operator |
|
|
|
(Options.OPTION_INNER |
|
|
|
(Options.OPTION_INNER |
|
|
|
| Options.OPTION_CONTRAFO)) == 0) { |
|
|
|
| Options.OPTION_CONTRAFO)) == 0) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (implicitOuterClass) { |
|
|
|
|
|
|
|
/* Outer class is "this" and is not given |
|
|
|
|
|
|
|
* explicitly. No need to print something. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
} else if (arg < length) { |
|
|
|
Expression outerExpr = jikesAnonymousInner |
|
|
|
Expression outerExpr = jikesAnonymousInner |
|
|
|
? subExpressions[--length] |
|
|
|
? subExpressions[--length] |
|
|
|
: subExpressions[arg++]; |
|
|
|
: subExpressions[arg++]; |
|
|
|
if (outerExpr instanceof CheckNullOperator) { |
|
|
|
if (outerExpr instanceof CheckNullOperator) { |
|
|
|
CheckNullOperator cno = (CheckNullOperator) outerExpr; |
|
|
|
CheckNullOperator cno = (CheckNullOperator) outerExpr; |
|
|
|
outerExpr = cno.subExpressions[0]; |
|
|
|
outerExpr = cno.subExpressions[0]; |
|
|
|
} else if (!(outerExpr instanceof ThisOperator)) { |
|
|
|
} else { |
|
|
|
// Complain about missing checknull, but not if
|
|
|
|
/* We used to complain about MISSING CHECKNULL |
|
|
|
// that is the known bug in jikes.
|
|
|
|
* here except for ThisOperators. But javac |
|
|
|
if (!jikesAnonymousInner) |
|
|
|
* v8 doesn't seem to create CHECKNULL ops. |
|
|
|
writer.print("MISSING CHECKNULL "); |
|
|
|
*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (outerExpr instanceof ThisOperator) { |
|
|
|
if (outerExpr instanceof ThisOperator) { |
|
|
@ -974,6 +1039,8 @@ public final class InvokeOperator extends Operator |
|
|
|
writer.breakOp(); |
|
|
|
writer.breakOp(); |
|
|
|
writer.print("."); |
|
|
|
writer.print("."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
writer.print("MISSING OUTEREXPR "); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (subExpressions[0] instanceof NewOperator |
|
|
|
if (subExpressions[0] instanceof NewOperator |
|
|
@ -1102,10 +1169,10 @@ public final class InvokeOperator extends Operator |
|
|
|
Scope scope = writer.getScope(thisOp.getClassInfo(), |
|
|
|
Scope scope = writer.getScope(thisOp.getClassInfo(), |
|
|
|
Scope.CLASSSCOPE); |
|
|
|
Scope.CLASSSCOPE); |
|
|
|
if (writer.conflicts(methodName, scope, Scope.METHODNAME) |
|
|
|
if (writer.conflicts(methodName, scope, Scope.METHODNAME) |
|
|
|
|| (/* This field is inherited from the parent of |
|
|
|
|| (/* This method is inherited from the parent of |
|
|
|
* an outer class, or it is inherited from the |
|
|
|
* an outer class, or it is inherited from the |
|
|
|
* parent of this class and there is a conflicting |
|
|
|
* parent of this class and there is a conflicting |
|
|
|
* field in some outer class. |
|
|
|
* method in some outer class. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getMethodAnalyzer() == null |
|
|
|
getMethodAnalyzer() == null |
|
|
|
&& (!isThis() || |
|
|
|
&& (!isThis() || |
|
|
|