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

Error handling lambda expressions #13

Open
nvvishnu opened this issue May 24, 2022 · 0 comments
Open

Error handling lambda expressions #13

nvvishnu opened this issue May 24, 2022 · 0 comments

Comments

@nvvishnu
Copy link

nvvishnu commented May 24, 2022

I am trying to run the DACAPO benchmark using TamiFlex to handle reflective calls. I am following the instructions mentioned here:
https://github.com/secure-software-engineering/tamiflex/wiki/DaCapoAndSoot

Dumped the class files and refl log for the batik-small benchmark using
java -javaagent:poa-2.0.3.jar -jar dacapo-9.12-bach.jar batik -s small

When I try running Soot using the refl log generated and the dumped class files, I get the following error:
Unknown method for signature: <java.awt.GraphicsEnvironment$$Lambda$1.2048834776: void ()>

To confirm the behaviour with lambda expressions, I wrote a simple program which uses lambda expressions:
// A Java program to demonstrate simple lambda expressions
import java.util.ArrayList;
public class tamiflex_lambda
{
public static void main(String args[])
{
// Creating an ArrayList with elements
// {1, 2, 3, 4}
ArrayList arrL = new ArrayList();
arrL.add(1);
arrL.add(2);
arrL.add(3);
arrL.add(4);

	// Using lambda expression to print all elements
	// of arrL
	arrL.forEach(n -> System.out.println(n));

	// Using lambda expression to print even elements
	// of arrL
	arrL.forEach(n -> { if (n%2 == 0) System.out.println(n); });
}

}
and dumped the refl.log and the class files.
The contents of the refl.log:
Constructor.newInstance;<tamiflex_lambda$$Lambda$1.2093631819: void ()>;java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite;215;isAccessible=true;
Constructor.newInstance;<tamiflex_lambda$$Lambda$2.1480010240: void ()>;java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite;215;isAccessible=true;

When I try running it on soot.Main, I get the following error:

java -cp .:soot-4.3.0-jar-with-dependencies.jar:out followup.Followup_Main_test java.util.List.add -f J
The soot arguments are [-v, -cp, .:out, -pp, -w, -app, -p, cg.spark, enabled:true, -p, cg, all-reachable:true, -p, cg, reflection-log:out/refl.log, -p, wjop.si, enabled:false, -verbose, -debug, -main-class, tamiflex_lambda, -f, J, -d, test, tamiflex_lambda]
Soot starting
Soot started on Tue May 24 17:08:37 IST 2022
java.lang.RuntimeException: Unknown method for signature: <tamiflex_lambda$$Lambda$1.2093631819: void ()>
at soot.jimple.toolkits.reflection.ReflectionTraceInfo.(ReflectionTraceInfo.java:118)
at soot.jimple.toolkits.callgraph.OnFlyCallGraphBuilder$TraceBasedReflectionModel.(OnFlyCallGraphBuilder.java:1163)
at soot.jimple.toolkits.callgraph.OnFlyCallGraphBuilder$TraceBasedReflectionModel.(OnFlyCallGraphBuilder.java:1152)
at soot.jimple.toolkits.callgraph.OnFlyCallGraphBuilder.(OnFlyCallGraphBuilder.java:234)
at soot.jimple.spark.solver.OnFlyCallGraph.createOnFlyCallGraphBuilder(OnFlyCallGraph.java:101)
at soot.jimple.spark.solver.OnFlyCallGraph.(OnFlyCallGraph.java:82)
at soot.jimple.spark.builder.ContextInsensitiveBuilder.setup(ContextInsensitiveBuilder.java:87)
at soot.jimple.spark.SparkTransformer.internalTransform(SparkTransformer.java:100)
at soot.SceneTransformer.transform(SceneTransformer.java:36)
at soot.Transform.apply(Transform.java:105)
at soot.RadioScenePack.internalApply(RadioScenePack.java:64)
at soot.jimple.toolkits.callgraph.CallGraphPack.internalApply(CallGraphPack.java:61)
at soot.Pack.apply(Pack.java:118)
at soot.PackManager.runWholeProgramPacks(PackManager.java:619)
at soot.PackManager.runPacksNormally(PackManager.java:500)
at soot.PackManager.runPacks(PackManager.java:425)
at soot.Main.run(Main.java:280)
at soot.Main.main(Main.java:142)
at followup.Followup_Main_test.main(Followup_Main_test.java:49)

When I decompile the tamiflex_lambda$$Lambda$1.class file using the command "javap -c tamiflex_lambda$$Lambda$1.class ", the contents are as follows:

final class tamiflex_lambda$$Lambda$1 implements java.util.function.Consumer {
public void accept(java.lang.Object);
Code:
0: aload_1
1: checkcast #15 // class java/lang/Integer
4: invokestatic #21 // Method tamiflex_lambda.lambda$main$0:(Ljava/lang/Integer;)V
7: return
}
It does not contain a constructor.

Is this to be expected? Can TamiFlex handle lambda expressions ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant