val p = Project(new java.io.File("/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/"))
// (1) Finding the call targets of invoke static calls
-p.allMethodsWithBody.forall {m => m.body.get.instructions.forall{
- case i : INVOKESTATIC =>
- val callTargets = p.invokestaticCall(i)
- // let's report unresolved call targets...
- if(callTargets.isEmpty) println(i)}
+p.allMethodsWithBody.foreach {m =>
+ m.body.get.instructions.foreach{
+ case i : INVOKESTATIC =>
+ val callTargets = p.staticCall(i)
+ // let's report unresolved call targets...
+ if(callTargets.isEmpty) println(i)
-// (e) Finding the call targets of instance based calls (where the runtime type of the instance is known)
+// (3) Finding the call targets of instance based calls (where the runtime type of the instance is known)
p.instanceCall(ObjectType("java/langutil/LinkedHashMap"),ObjectType("java/util/AbstractCollection"),"spliterator",MethodDescriptor(IndexedSeq(),ObjectType("java/util/Spliterator"))).map(m => m.toJava(p.classFile(m)))
p.instanceCall(ObjectType.String,ObjectType("java/util/HashMap"),"reinitialize",MethodDescriptor.NoArgsAndReturnVoid)
// => <NO METHOD> (reinitialize is only package visible)
-p.instanceCall(ObjectType("java/util/LinkedHashMap"),ObjectType("java/util/HashMap"),"reinitialize",MethodDescriptor.NoArgsAndReturnVoid)
+p.instanceCall(ObjectType("java/util/LinkedHashMap"),ObjectType("java/util/HashMap"),"reinitialize",MethodDescriptor.NoArgsAndReturnVoid)p.instanceCall(ObjectType("java/util/LinkedHashMap"),ObjectType("java/util/HashMap"),"reinitialize",MethodDescriptor.NoArgsAndReturnVoid)
// => package visible reinitialize method
/////// HANDLING POLYMORPHIC CALLS
p.instanceCall(ObjectType.Object/*IRRELEVANT*/,ObjectType.MethodHandle,"invoke",MethodDescriptor.NoArgsAndReturnVoid)
p.instanceCall(ObjectType.Object/*IRRELEVANT*/,ObjectType.MethodHandle,"invoke",MethodDescriptor.JustReturnsDouble)
p.instanceCall(ObjectType.Object/*IRRELEVANT*/,ObjectType.MethodHandle,"invokeExact",MethodDescriptor.NoArgsAndReturnVoid)
-p.instanceCall(ObjectType.Object/*IRRELEVANT*/,ObjectType.MethodHandle,"invokeExact",MethodDescriptor.SignaturePolymorphic)
+p.instanceCall(ObjectType.Object/*IRRELEVANT*/,ObjectType.MethodHandle,"invokeExact",MethodDescriptor.SignaturePolymorphicMethod)
p.instanceCall(ObjectType.Object/*IRRELEVANT*/,ObjectType.MethodHandle,"invokeExacter",MethodDescriptor.NoArgsAndReturnVoid)
// should not resolve (name does not exist)
p.instanceCall(ObjectType.Object/*IRRELEVANT*/,ObjectType.MethodHandle,"invokeWithArguments",MethodDescriptor.NoArgsAndReturnVoid)
// should not resolve (invokeWithArguments is not signature polymorphic because the flags don't fit!)
+p.instanceCall(ObjectType.Object/*IRRELEVANT*/,ObjectType.MethodHandle,"invokeWithArguments",MethodDescriptor.SignaturePolymorphicMethod)
+// should resolve as usual