From b29998ee5647e2e5ea072e37293775410c7aa4c1 Mon Sep 17 00:00:00 2001 From: yeom Date: Wed, 29 Jun 2011 18:11:45 +0000 Subject: [PATCH] add ssjava debug option to have interim results if we want and small changes --- Robust/src/Analysis/SSJava/FlowDownCheck.java | 6 ++-- .../SSJava/MethodAnnotationCheck.java | 8 ++--- .../src/Analysis/SSJava/SSJavaAnalysis.java | 33 ++++++++++++------- .../Analysis/SSJava/SingleReferenceCheck.java | 2 +- Robust/src/IR/State.java | 1 + Robust/src/Main/Main.java | 4 ++- 6 files changed, 34 insertions(+), 20 deletions(-) diff --git a/Robust/src/Analysis/SSJava/FlowDownCheck.java b/Robust/src/Analysis/SSJava/FlowDownCheck.java index db16bef9..71537e2a 100644 --- a/Robust/src/Analysis/SSJava/FlowDownCheck.java +++ b/Robust/src/Analysis/SSJava/FlowDownCheck.java @@ -114,7 +114,7 @@ public class FlowDownCheck { checkDeclarationInClass(cd); for (Iterator method_it = cd.getMethods(); method_it.hasNext();) { MethodDescriptor md = (MethodDescriptor) method_it.next(); - if (ssjava.needAnnotation(md)) { + if (ssjava.needTobeAnnotated(md)) { checkDeclarationInMethodBody(cd, md); } } @@ -133,7 +133,7 @@ public class FlowDownCheck { checkClass(cd); for (Iterator method_it = cd.getMethods(); method_it.hasNext();) { MethodDescriptor md = (MethodDescriptor) method_it.next(); - if (ssjava.needAnnotation(md)) { + if (ssjava.needTobeAnnotated(md)) { checkMethodBody(cd, md); } } @@ -176,7 +176,7 @@ public class FlowDownCheck { BlockNode bn = state.getMethodBody(md); // parsing returnloc annotation - if (ssjava.needAnnotation(md)) { + if (ssjava.needTobeAnnotated(md)) { Vector methodAnnotations = md.getModifiers().getAnnotations(); if (methodAnnotations != null) { diff --git a/Robust/src/Analysis/SSJava/MethodAnnotationCheck.java b/Robust/src/Analysis/SSJava/MethodAnnotationCheck.java index fa628062..587bc28d 100644 --- a/Robust/src/Analysis/SSJava/MethodAnnotationCheck.java +++ b/Robust/src/Analysis/SSJava/MethodAnnotationCheck.java @@ -71,7 +71,7 @@ public class MethodAnnotationCheck { for (Iterator iterator = annotatedMDSet.iterator(); iterator.hasNext();) { MethodDescriptor md = (MethodDescriptor) iterator.next(); - ssjava.putNeedAnnotation(md); + ssjava.addAnnotationRequire(md); } Set visited = new HashSet(); @@ -89,7 +89,7 @@ public class MethodAnnotationCheck { if (!visited.contains(p)) { visited.add(p); tovisit.add(calleeMD); - ssjava.putNeedAnnotation(calleeMD); + ssjava.addAnnotationRequire(calleeMD); } } } @@ -102,7 +102,7 @@ public class MethodAnnotationCheck { // be annotated. Set tovisit = new HashSet(); - tovisit.addAll(ssjava.getMd2hasAnnotation().keySet()); + tovisit.addAll(ssjava.getAnnotationRequireSet()); while (!tovisit.isEmpty()) { MethodDescriptor md = tovisit.iterator().next(); @@ -119,7 +119,7 @@ public class MethodAnnotationCheck { MethodDescriptor matchmd = (MethodDescriptor) methodit.next(); if (md.matches(matchmd)) { if (matchmd.getClassDesc().equals(subCD)) { - ssjava.putNeedAnnotation(matchmd); + ssjava.addAnnotationRequire(matchmd); } } } diff --git a/Robust/src/Analysis/SSJava/SSJavaAnalysis.java b/Robust/src/Analysis/SSJava/SSJavaAnalysis.java index ca98c6be..c9e0e900 100644 --- a/Robust/src/Analysis/SSJava/SSJavaAnalysis.java +++ b/Robust/src/Analysis/SSJava/SSJavaAnalysis.java @@ -1,5 +1,6 @@ package Analysis.SSJava; +import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.Set; @@ -33,7 +34,7 @@ public class SSJavaAnalysis { MethodAnnotationCheck methodAnnotationChecker; // if a method has annotations, the mapping has true - Hashtable md2needAnnotation; + Set annotationRequireSet; // class -> field lattice Hashtable> cd2lattice; @@ -53,18 +54,29 @@ public class SSJavaAnalysis { this.cd2lattice = new Hashtable>(); this.cd2methodDefault = new Hashtable>(); this.md2lattice = new Hashtable>(); - this.md2needAnnotation = new Hashtable(); + this.annotationRequireSet = new HashSet(); this.skipLoopTerminate = new Hashtable(); } public void doCheck() { doMethodAnnotationCheck(); + if (state.SSJAVADEBUG) { + debugPrint(); + } parseLocationAnnotation(); doFlowDownCheck(); doDefinitelyWrittenCheck(); doSingleReferenceCheck(); } + public void debugPrint() { + System.out.println("SSJAVA: SSJava is checking the following methods:"); + for (Iterator iterator = annotationRequireSet.iterator(); iterator.hasNext();) { + MethodDescriptor md = iterator.next(); + System.out.println("SSJAVA: " + md); + } + } + private void doMethodAnnotationCheck() { methodAnnotationChecker = new MethodAnnotationCheck(this, state, tu); methodAnnotationChecker.methodAnnoatationCheck(); @@ -112,7 +124,7 @@ public class SSJavaAnalysis { MethodDescriptor md = (MethodDescriptor) method_it.next(); // parsing location hierarchy declaration for the method - if (needAnnotation(md)) { + if (needTobeAnnotated(md)) { Vector methodAnnotations = md.getModifiers().getAnnotations(); if (methodAnnotations != null) { for (int i = 0; i < methodAnnotations.size(); i++) { @@ -249,22 +261,21 @@ public class SSJavaAnalysis { } } - public boolean needAnnotation(MethodDescriptor md) { - return md2needAnnotation.containsKey(md); + public boolean needTobeAnnotated(MethodDescriptor md) { + return annotationRequireSet.contains(md); } - public void putNeedAnnotation(MethodDescriptor md) { - md2needAnnotation.put(md, new Boolean(true)); + public void addAnnotationRequire(MethodDescriptor md) { + annotationRequireSet.add(md); } - public Hashtable getMd2hasAnnotation() { - return md2needAnnotation; + public Set getAnnotationRequireSet() { + return annotationRequireSet; } public void doLoopTerminationCheck(LoopOptimize lo) { LoopTerminate lt = new LoopTerminate(); - Set mdSet = md2needAnnotation.keySet(); - for (Iterator iterator = mdSet.iterator(); iterator.hasNext();) { + for (Iterator iterator = annotationRequireSet.iterator(); iterator.hasNext();) { MethodDescriptor md = (MethodDescriptor) iterator.next(); if (!skipLoopTerminate.containsKey(md)) { FlatMethod fm = state.getMethodFlat(md); diff --git a/Robust/src/Analysis/SSJava/SingleReferenceCheck.java b/Robust/src/Analysis/SSJava/SingleReferenceCheck.java index 5ef3452c..baae40db 100644 --- a/Robust/src/Analysis/SSJava/SingleReferenceCheck.java +++ b/Robust/src/Analysis/SSJava/SingleReferenceCheck.java @@ -33,7 +33,7 @@ public class SingleReferenceCheck { ClassDescriptor cd = (ClassDescriptor) it.next(); for (Iterator method_it = cd.getMethods(); method_it.hasNext();) { MethodDescriptor md = (MethodDescriptor) method_it.next(); - if (ssjava.needAnnotation(md)) { + if (ssjava.needTobeAnnotated(md)) { checkMethodBody(cd, md); } } diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index bb692cd4..c4016aa9 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -140,6 +140,7 @@ public class State { //SSJava public boolean SSJAVA=false; + public boolean SSJAVADEBUG=false; public boolean OPTIONAL=false; diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index e8ae399d..d7d3c7ec 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -360,7 +360,9 @@ public class Main { state.NOSTALLTR = true; } else if (option.equals("-ssjava")) { state.SSJAVA = true; - } else if (option.equals("-printlinenum")) { + } else if (option.equals("-ssjavadebug")) { + state.SSJAVADEBUG = true; + }else if (option.equals("-printlinenum")) { state.LINENUM=true; } else if (option.equals("-help")) { System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located"); -- 2.34.1