diff src/main/gov/nasa/jpf/vm/ClassInfo.java @ 17:e15b03204dc7

added a @NoJPFExecution annotation, which sets a NoJPFExec system attr on marked methods during class load time, which gets checked by ThreadInfo.enter(). Useful to flag methods which have to be intercepted/cut off when executing classes under JPF that can also be used outside. Especially useful to avoid the recursive JPF problem that can be caused by tests (which mix classpath and native_classpath). This currently throws a JPFException, but we could also turn this into a AssertionError in the SUT so that we get the SUT stack trace
author Peter Mehlitz <pcmehlitz@gmail.com>
date Mon, 23 Mar 2015 12:54:20 -0700
parents b822e7665585
children db918c531e6d
line wrap: on
line diff
--- a/src/main/gov/nasa/jpf/vm/ClassInfo.java	Fri Mar 20 15:47:10 2015 -0700
+++ b/src/main/gov/nasa/jpf/vm/ClassInfo.java	Mon Mar 23 12:54:20 2015 -0700
@@ -363,7 +363,7 @@
           instanceFields[iInstance++] = fi;
         }
         
-        processJPFAttrAnnotation(fi);
+        processJPFAnnotations(fi);
       }
 
       iFields = instanceFields;
@@ -376,7 +376,7 @@
   protected void setMethod (MethodInfo mi){
     mi.linkToClass(this);
     methods.put( mi.getUniqueName(), mi);
-    processJPFAttrAnnotation(mi);
+    processJPFAnnotations(mi);
   }
   
   public void setMethods (MethodInfo[] newMethods) {
@@ -416,7 +416,19 @@
     }    
   }
 
-  public AnnotationInfo getResolvedAnnotationInfo (String typeName){
+  protected void processNoJPFExecutionAnnotation(InfoObject infoObj) {
+    AnnotationInfo ai = infoObj.getAnnotation("gov.nasa.jpf.annotation.NoJPFExecution");
+    if (ai != null) {
+      infoObj.addAttr(NoJPFExec.SINGLETON);
+    }
+  }
+
+  protected void processJPFAnnotations(InfoObject infoObj) {
+    processJPFAttrAnnotation(infoObj);
+    processNoJPFExecutionAnnotation(infoObj);
+  }
+
+    public AnnotationInfo getResolvedAnnotationInfo (String typeName){
     return classLoader.getResolvedAnnotationInfo( typeName);
   }
   
@@ -542,7 +554,7 @@
     
     setAssertionStatus();
     processJPFConfigAnnotation();
-    processJPFAttrAnnotation(this);
+    processJPFAnnotations(this);
     loadAnnotationListeners();    
   }
   
@@ -1658,8 +1670,6 @@
 
   /**
    * Loads the ClassInfo for named class.
-   * @param set a Set to which the interface names (String) are added
-   * @param ifcs class to find interfaceNames for.
    */
   void loadInterfaceRec (Set<ClassInfo> set, String[] interfaces) throws ClassInfoException {
     if (interfaces != null) {