-
Notifications
You must be signed in to change notification settings - Fork 181
Fix ReflectionAnalysis plugin to enable AnnotationModel only for Java 5+ #159
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @FoggyDawn,
Thanks for your contribution to Tai-e! 😀
Although no instructions were provided on how to reproduce this error, this appears to be an intuitive fix. When the Java version is less than 5, the JRE does not contain the class java.lang.annotation.Annotation
, causing
Tai-e/src/main/java/pascal/taie/analysis/pta/plugin/reflection/AnnotationModel.java
Line 63 in bb5141b
this.annotation = hierarchy.getClass(ClassNames.ANNOTATION); |
I am inclined to fix this directly with some minor modifications required:
- Use a concise but informative English PR title with proper capitalization, which will later serve as the commit message
- Change
World.get().getOptions().getJavaVersion() > 4
toWorld.get().getOptions().getJavaVersion() >= 5
, because5
more directly indicates that Annotations are available from Java 1.5 onwards (including 1.5). Using4
would require an additional mental step to understand the logic.
Thanks for reviewing |
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #159 +/- ##
============================================
- Coverage 72.80% 72.78% -0.03%
+ Complexity 4429 4428 -1
============================================
Files 480 480
Lines 15917 15919 +2
Branches 2181 2182 +1
============================================
- Hits 11589 11587 -2
- Misses 3477 3480 +3
- Partials 851 852 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Please fix the style issue in https://github.com/pascal-lab/Tai-e/actions/runs/15249916817/job/42888063169?pr=159#step:5:67: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Welcome to become a Tai-e contributor!
test case:
Xcorpus--emma-2.0.5312
error log before repair:
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "Object.equals(Object)" because "superclass" is null
at pascal.taie.language.classes.ClassHierarchyImpl.isSubclass(ClassHierarchyImpl.java:397)
at pascal.taie.analysis.pta.plugin.reflection.AnnotationModel.onUnresolvedCall(AnnotationModel.java:79)
at pascal.taie.analysis.pta.plugin.CompositePlugin.lambda$onUnresolvedCall$6(CompositePlugin.java:147)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at pascal.taie.analysis.pta.plugin.CompositePlugin.onUnresolvedCall(CompositePlugin.java:147)
at pascal.taie.analysis.pta.plugin.CompositePlugin.lambda$onUnresolvedCall$6(CompositePlugin.java:147)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at pascal.taie.analysis.pta.plugin.CompositePlugin.onUnresolvedCall(CompositePlugin.java:147)
at pascal.taie.analysis.pta.core.solver.DefaultSolver.lambda$processCall$9(DefaultSolver.java:490)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at pascal.taie.analysis.pta.core.solver.DefaultSolver.processCall(DefaultSolver.java:471)
at pascal.taie.analysis.pta.core.solver.DefaultSolver.analyze(DefaultSolver.java:321)
at pascal.taie.analysis.pta.core.solver.DefaultSolver.solve(DefaultSolver.java:248)
at pascal.taie.analysis.pta.PointerAnalysis.runAnalysis(PointerAnalysis.java:119)
at pascal.taie.analysis.pta.PointerAnalysis.analyze(PointerAnalysis.java:107)
at pascal.taie.analysis.pta.PointerAnalysis.analyze(PointerAnalysis.java:64)
at pascal.taie.analysis.AnalysisManager.runProgramAnalysis(AnalysisManager.java:148)
at pascal.taie.analysis.AnalysisManager.runAnalysis(AnalysisManager.java:135)
at pascal.taie.analysis.AnalysisManager.lambda$execute$0(AnalysisManager.java:104)
at pascal.taie.util.Timer.runAndCount(Timer.java:93)
at pascal.taie.analysis.AnalysisManager.lambda$execute$1(AnalysisManager.java:103)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at pascal.taie.analysis.AnalysisManager.execute(AnalysisManager.java:102)
at pascal.taie.Main.executePlan(Main.java:154)
at pascal.taie.Main.lambda$main$0(Main.java:62)
at pascal.taie.util.Timer.lambda$runAndCount$0(Timer.java:112)
at pascal.taie.util.Timer.runAndCount(Timer.java:93)
at pascal.taie.util.Timer.runAndCount(Timer.java:111)
at pascal.taie.util.Timer.runAndCount(Timer.java:107)
at pascal.taie.Main.main(Main.java:52)
log after repair:
[Pointer analysis] elapsed time: 3.07s
-------------- Pointer analysis statistics: --------------
#var pointers: 2,8638 (insens) / 9,7641 (sens)
#objects: 2760 (insens) / 2782 (sens)
#var points-to: 37,9909 (insens) / 236,6762 (sens)
#static field points-to: 1000 (sens)
#instance field points-to: 3,8875 (sens)
#array points-to: 6411 (sens)
#reachable methods: 3937 (insens) / 2,0121 (sens)
#call graph edges: 1,9950 (insens) / 8,6376 (sens)
pta finishes, elapsed time: 3.54s
cg starts ...
Call graph has 3937 reachable methods and 19950 edges
Dumping call graph to /home/byx/testSpace/javaprjs/emma-2.0.5312/cs1call-output/call-graph.dot
Dumping reachable methods to /home/byx/testSpace/javaprjs/emma-2.0.5312/cs1call-output/reachable-methods.txt
Dumping call edges to /home/byx/testSpace/javaprjs/emma-2.0.5312/cs1call-output/call-edges.txt
cg finishes, elapsed time: 0.41s
Tai-e finishes, elapsed time: 7.51s
options:
optionsFile: null
printHelp: false
classPath:
appClassPath:
mainClass: emma
inputClasses: []
javaVersion: 3
prependJVM: false
allowPhantom: true
worldBuilderClass: pascal.taie.frontend.soot.SootWorldBuilder
outputDir: ../../testSpace/javaprjs/emma-2.0.5312/cs1call-output
preBuildIR: false
worldCacheMode: false
scope: APP
nativeModel: true
planFile: null
analyses:
pta: cs:1-call;implicit-entries:false;handle-invokedynamic:true
cg: algorithm:pta;dump:true;dump-methods:true;dump-call-edges:true;
onlyGenPlan: false
keepResult: